Spaces:
Build error
Build error
Fixing errors due to using OpenAI's client object
Browse files- openai_api.py +7 -7
openai_api.py
CHANGED
|
@@ -21,18 +21,18 @@ def get_embedding(text: str, model: str=EMBEDDING_MODEL) -> list[float]:
|
|
| 21 |
model=model,
|
| 22 |
input=text
|
| 23 |
)
|
| 24 |
-
return result
|
| 25 |
|
| 26 |
|
| 27 |
-
def get_response(prompt: str, model: str=COMPLETIONS_MODEL) ->
|
| 28 |
"""Chat completion using OpenAI's GPT models."""
|
| 29 |
response = client.chat.completions.create(
|
| 30 |
-
model
|
| 31 |
messages=[
|
| 32 |
-
|
| 33 |
-
|
| 34 |
],
|
| 35 |
temperature=0,
|
| 36 |
-
|
| 37 |
)
|
| 38 |
-
return response
|
|
|
|
| 21 |
model=model,
|
| 22 |
input=text
|
| 23 |
)
|
| 24 |
+
return result.data[0].embedding
|
| 25 |
|
| 26 |
|
| 27 |
+
def get_response(prompt: str, model: str=COMPLETIONS_MODEL) -> str:
|
| 28 |
"""Chat completion using OpenAI's GPT models."""
|
| 29 |
response = client.chat.completions.create(
|
| 30 |
+
model=model,
|
| 31 |
messages=[
|
| 32 |
+
{"role": "system", "content": META_PROMPT},
|
| 33 |
+
{"role": "user", "content": prompt}
|
| 34 |
],
|
| 35 |
temperature=0,
|
| 36 |
+
max_tokens=800
|
| 37 |
)
|
| 38 |
+
return response.choices[0].message.content
|