DevsDoCode commited on
Commit
42f61c6
·
verified ·
1 Parent(s): b6fec12

Delete mistral_8x7b_yepchat.py

Browse files
Files changed (1) hide show
  1. mistral_8x7b_yepchat.py +0 -54
mistral_8x7b_yepchat.py DELETED
@@ -1,54 +0,0 @@
1
- import requests
2
- import json
3
-
4
- class Mistral_Inference:
5
- def __init__(self, max_tokens=2048, temperature=0.7, message=""):
6
- self.url = "https://api.yep.com/v1/chat/completions"
7
- self.headers = {
8
- "Accept": "*/*",
9
- "Accept-Encoding": "gzip, deflate, br, zstd",
10
- "Accept-Language": "en-US,en;q=0.9",
11
- "Content-Type": "application/json; charset=utf-8",
12
- "Origin": "https://yep.com",
13
- "Referer": "https://yep.com/",
14
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0.0.0 Safari/537.36"
15
- }
16
- self.payload = {
17
- "stream": True,
18
- "max_tokens": max_tokens,
19
- "top_p": temperature,
20
- "temperature": 0.6,
21
- "messages": [{"content": message, "role": "user"}],
22
- "model": "Mixtral-8x7B-Instruct-v0.1"
23
- }
24
-
25
- def send_request(self):
26
- return requests.post(self.url, headers=self.headers, data=json.dumps(self.payload), stream=False)
27
-
28
- def process_response(self, response):
29
- processed_text = ""
30
- for line in response.iter_lines():
31
- if line:
32
- try:
33
- line_dict = json.loads(line.decode('utf-8')[6:])
34
- if "choices" in line_dict and line_dict["choices"][0].get("delta", {}).get("content"):
35
- processed_text += line_dict["choices"][0]["delta"]["content"]
36
- except:
37
- continue
38
- return processed_text
39
-
40
- def chat(self, message):
41
- self.payload["messages"][0]["content"] = message
42
- response = self.send_request()
43
- processed_response = self.process_response(response)
44
- # print(processed_response.strip())
45
- return processed_response.strip()
46
-
47
-
48
- if __name__ =="__main__":
49
- query = "What is the capital of India"
50
- # Then, create an instance of the YepChat class
51
- mistral_chat_instance = Mistral_Inference(max_tokens=2048, temperature=0.7)
52
-
53
- # Next, call the chat method with your desired message
54
- mistral_chat_instance.chat("who developed you")