Spaces:
Runtime error
Runtime error
Commit
·
862c4a8
1
Parent(s):
e58d90f
Update app.py
Browse files
app.py
CHANGED
@@ -92,17 +92,20 @@ async def get_answer(q: Query ):
|
|
92 |
async def get_answer(q: QueryM ):
|
93 |
text = q.text
|
94 |
try:
|
95 |
-
|
96 |
generate_kwargs = dict(
|
97 |
max_new_tokens=q.tokens,
|
98 |
do_sample=True,
|
99 |
top_p=q.topp,
|
100 |
top_k=q.topk,
|
101 |
temperature=q.temp,
|
102 |
-
|
103 |
inputs= text
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
106 |
x=x.replace(inputs,'')
|
107 |
return JSONResponse({"result":x,"status":True})
|
108 |
except Exception as e:
|
|
|
92 |
async def get_answer(q: QueryM ):
|
93 |
text = q.text
|
94 |
try:
|
95 |
+
client = InferenceClient()
|
96 |
generate_kwargs = dict(
|
97 |
max_new_tokens=q.tokens,
|
98 |
do_sample=True,
|
99 |
top_p=q.topp,
|
100 |
top_k=q.topk,
|
101 |
temperature=q.temp,
|
102 |
+
)
|
103 |
inputs= text
|
104 |
+
response = client.post(json={"inputs": inputs, "parameters": generate_kwargs}, model="mistralai/Mistral-7B-Instruct-v0.1")
|
105 |
+
json_string = response.decode('utf-8')
|
106 |
+
list_of_dicts = json.loads(json_string)
|
107 |
+
result_dict = list_of_dicts[0]
|
108 |
+
x=(result_dict['generated_text'])
|
109 |
x=x.replace(inputs,'')
|
110 |
return JSONResponse({"result":x,"status":True})
|
111 |
except Exception as e:
|