marcofrodl commited on
Commit
752f525
·
1 Parent(s): 3c6e762

Delete src/request.py

Browse files
Files changed (1) hide show
  1. src/request.py +0 -31
src/request.py DELETED
@@ -1,31 +0,0 @@
1
- """
2
- Perform requests to Mistral AI API
3
- """
4
-
5
- from mistralai.client import MistralClient
6
- from mistralai.models.chat_completion import ChatMessage
7
-
8
-
9
- def get_stream_chat_completion(
10
- message, chat_history, model, api_key, system=None, **kwargs
11
- ):
12
- messages = []
13
- if system is not None:
14
- messages.append(ChatMessage(role="system", content=system))
15
- for chat in chat_history:
16
- human_message, bot_message = chat
17
- messages.extend(
18
- (
19
- ChatMessage(role="user", content=human_message),
20
- ChatMessage(role="assistant", content=bot_message),
21
- )
22
- )
23
- messages.append(ChatMessage(role="user", content=message))
24
- client = MistralClient(api_key=api_key)
25
- for chunk in client.chat_stream(
26
- model=model,
27
- messages=messages,
28
- **kwargs,
29
- ):
30
- if chunk.choices[0].delta.content is not None:
31
- yield chunk.choices[0].delta.content