Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,11 +23,26 @@ llm = Llama(
|
|
23 |
@app.get("/")
|
24 |
async def generate_text():
|
25 |
try:
|
|
|
26 |
output = llm(
|
27 |
"Q: Name the planets in the solar system? A: ",
|
28 |
max_tokens=32,
|
29 |
stop=["Q:", "\n"],
|
30 |
echo=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
return output
|
32 |
except Exception as e:
|
33 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
23 |
@app.get("/")
|
24 |
async def generate_text():
|
25 |
try:
|
26 |
+
"""
|
27 |
output = llm(
|
28 |
"Q: Name the planets in the solar system? A: ",
|
29 |
max_tokens=32,
|
30 |
stop=["Q:", "\n"],
|
31 |
echo=True)
|
32 |
+
"""
|
33 |
+
output = llm.create_chat_completion(
|
34 |
+
messages=[
|
35 |
+
{
|
36 |
+
"role": "system",
|
37 |
+
"content": "You are a helpful assistant that outputs in JSON.",
|
38 |
+
},
|
39 |
+
{"role": "user", "content": "Who won the world series in 2020"},
|
40 |
+
],
|
41 |
+
response_format={
|
42 |
+
"type": "json_object",
|
43 |
+
},
|
44 |
+
temperature=0.7,
|
45 |
+
)
|
46 |
return output
|
47 |
except Exception as e:
|
48 |
raise HTTPException(status_code=500, detail=str(e))
|