Nitzantry1 commited on
Commit
b4ab413
โ€ข
1 Parent(s): eff6cb5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -9
app.py CHANGED
@@ -11,15 +11,11 @@ generator = InferenceApi(repo_id=model_id, token=api_key)
11
  # ืคื•ื ืงืฆื™ื™ืช ื™ืฆื™ืจืช ื”ื˜ืงืกื˜
12
  def chat_with_model(history):
13
  prompt = history[-1]["content"]
14
- response = generator(prompt, parameters={
15
- "do_sample": True,
16
- "min_length": 20,
17
- "max_length": 64,
18
- "top_k": 40,
19
- "top_p": 0.92,
20
- "temperature": 0.9
21
- })
22
- result = response["generated_text"]
23
  return history + [{"role": "bot", "content": result}]
24
 
25
  # ื™ืฆื™ืจืช ืžืžืฉืง ืžืชืงื“ื ืขื Gradio ื‘ืฆื•ืจืช ืฆ'ื˜-ื‘ื•ื˜ ื‘ืกื’ื ื•ืŸ ืืงื“ืžื™
 
11
  # ืคื•ื ืงืฆื™ื™ืช ื™ืฆื™ืจืช ื”ื˜ืงืกื˜
12
  def chat_with_model(history):
13
  prompt = history[-1]["content"]
14
+ try:
15
+ response = generator(prompt)
16
+ result = response["generated_text"] if "generated_text" in response else response
17
+ except Exception as e:
18
+ result = f"Error: {str(e)}"
 
 
 
 
19
  return history + [{"role": "bot", "content": result}]
20
 
21
  # ื™ืฆื™ืจืช ืžืžืฉืง ืžืชืงื“ื ืขื Gradio ื‘ืฆื•ืจืช ืฆ'ื˜-ื‘ื•ื˜ ื‘ืกื’ื ื•ืŸ ืืงื“ืžื™