Update run.py
Browse files
run.py
CHANGED
|
@@ -80,8 +80,18 @@ collection = client.get_collection(name="chromaTS", embedding_function=sentence_
|
|
| 80 |
|
| 81 |
inference_client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
def format_prompt(message, history):
|
| 87 |
print("HISTORY")
|
|
@@ -112,6 +122,7 @@ def response(request: gr.Request,prompt, history, temperature=0.9, max_new_token
|
|
| 112 |
|
| 113 |
print(f"Working with URL: {url_extracted}")
|
| 114 |
headers = request.headers
|
|
|
|
| 115 |
print(headers)
|
| 116 |
temperature = float(temperature)
|
| 117 |
if temperature < 1e-2: temperature = 1e-2
|
|
@@ -143,7 +154,7 @@ def response(request: gr.Request,prompt, history, temperature=0.9, max_new_token
|
|
| 143 |
output += response.token.text
|
| 144 |
yield output
|
| 145 |
now = str(datetime.now())
|
| 146 |
-
save_to_sheet(now, prompt, output)
|
| 147 |
yield output
|
| 148 |
|
| 149 |
gr.ChatInterface(
|
|
|
|
| 80 |
|
| 81 |
inference_client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
| 82 |
|
| 83 |
+
def extract_ip_and_device(headers):
|
| 84 |
+
ip_address = None
|
| 85 |
+
device_info = None
|
| 86 |
+
|
| 87 |
+
for header in headers:
|
| 88 |
+
key, value = header
|
| 89 |
+
if key == b'x-forwarded-for':
|
| 90 |
+
ip_address = value.decode('utf-8')
|
| 91 |
+
elif key == b'user-agent':
|
| 92 |
+
device_info = value.decode('utf-8')
|
| 93 |
+
|
| 94 |
+
return ip_address, device_info
|
| 95 |
|
| 96 |
def format_prompt(message, history):
|
| 97 |
print("HISTORY")
|
|
|
|
| 122 |
|
| 123 |
print(f"Working with URL: {url_extracted}")
|
| 124 |
headers = request.headers
|
| 125 |
+
IP, dev = extract_ip_and_device(headers)
|
| 126 |
print(headers)
|
| 127 |
temperature = float(temperature)
|
| 128 |
if temperature < 1e-2: temperature = 1e-2
|
|
|
|
| 154 |
output += response.token.text
|
| 155 |
yield output
|
| 156 |
now = str(datetime.now())
|
| 157 |
+
save_to_sheet(now, prompt, output, IP, dev, headers)
|
| 158 |
yield output
|
| 159 |
|
| 160 |
gr.ChatInterface(
|