rockerritesh commited on
Commit
5535935
·
verified ·
1 Parent(s): 51ef325

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +18 -1
utils.py CHANGED
@@ -169,4 +169,21 @@ def translate_text(text, target_language):
169
  )
170
  # print(response.choices[0].message.content)
171
  response = response.choices[0].message.content
172
- return response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  )
170
  # print(response.choices[0].message.content)
171
  response = response.choices[0].message.content
172
+ return response
173
+
174
+
175
+ def chat_text(system,query,history):
176
+ client = OpenAI()
177
+
178
+ completion = client.chat.completions.create(
179
+ model="gpt-4o",
180
+ messages=[
181
+ {"role": "system", "content": f"Here is the text you have to answer based on this. Knowledge Base:-{system}. \n History: {history}"},
182
+ {
183
+ "role": "user",
184
+ "content": query
185
+ }
186
+ ]
187
+ )
188
+
189
+ return completion.choices[0].message