Pamudu13 commited on
Commit
b444562
·
verified ·
1 Parent(s): 8674b83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -42,13 +42,16 @@ def chat_bot():
42
  first_message = False
43
  history.append({"role": "user", "content": message})
44
 
45
- # Use the correct OpenAI API method for the version you are using
46
- response = openai.Completion.create(
47
- model="gpt-3.5-turbo",
48
- prompt="\n".join([msg['content'] for msg in history]),
49
- max_tokens=150
50
- ).choices[0].text.strip()
51
-
 
 
 
52
  history.append({"role": "assistant", "content": response})
53
 
54
  # Trim history to keep within the word limit
 
42
  first_message = False
43
  history.append({"role": "user", "content": message})
44
 
45
+ # Use the Cosmo-RP model for the completion request
46
+ try:
47
+ response = openai.Completion.create(
48
+ model="Cosmo-RP",
49
+ prompt="\n".join([msg['content'] for msg in history]),
50
+ max_tokens=150
51
+ ).choices[0].text.strip()
52
+ except Exception as e:
53
+ return jsonify({"error": str(e)}), 500
54
+
55
  history.append({"role": "assistant", "content": response})
56
 
57
  # Trim history to keep within the word limit