Skip to content

Commit

Permalink
Update mistral.py
Browse files Browse the repository at this point in the history
- Removed redundant code.
  • Loading branch information
RMNCLDYO authored Mar 3, 2024
1 parent 4827c5a commit ef47cf1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions mistral.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Mistral:
def __init__(self):
self.client = None

def chat(self, api_key=None, model="mistral-large-latest", json=False, system_prompt=None, temperature=None, top_p=None, max_tokens=None, stream=None, safe_prompt=None, random_seed=None):
def chat(self, api_key=None, model="mistral-large-latest", json=None, system_prompt=None, temperature=None, top_p=None, max_tokens=None, stream=None, safe_prompt=None, random_seed=None):

self.client = Client(api_key=api_key)

Expand Down Expand Up @@ -41,17 +41,15 @@ async def conversation():

if stream:
response = await self.client.stream_post(endpoint, data)
assistant_response = response
else:
response = await self.client.post(endpoint, data)
assistant_response = response
print(f"Assistant: {assistant_response}")
conversation_history.append({"role": "assistant", "content": assistant_response})
print(f"Assistant: {response}")
conversation_history.append({"role": "assistant", "content": response})

try:
asyncio.run(conversation())
except RuntimeError as e:
if str(e) == 'This conversation loop is already running':
print("Event conversation loop is already running. Skipping asyncio.run() to avoid conflict.")
else:
raise
raise

0 comments on commit ef47cf1

Please sign in to comment.