DeMaking commited on
Commit
b60a7a6
verified
1 Parent(s): 89ffc46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -2,24 +2,24 @@ import os
2
  import logging
3
  from fastapi import FastAPI, Request
4
  import subprocess
5
- from huggingface_hub import InferenceClient, login, configure_http_backend, get_session
6
  import langid
7
- import requests
8
 
9
 
10
- # Create a factory function that returns a requests.Session object
11
- def backend_factory() -> requests.Session:
12
- session = requests.Session()
13
- # session.proxies = {"http": "http://your-proxy-host:your-proxy-port",
14
- # "https": "http://your-proxy-host:your-proxy-port"}
15
- return session
16
 
17
- # Set our custom backend factory as the default HTTP backend
18
- configure_http_backend(backend_factory=backend_factory)
19
 
20
- # For debugging
21
- session = get_session()
22
- print("Configured session:", session)
23
 
24
  # Configure logging
25
  logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s", level=logging.INFO)
@@ -69,10 +69,10 @@ def generate_response(text):
69
  if language == "hebrew":
70
  # Hebrew prompt: answer shortly but explain your decision-making process
71
  content = "转砖诪讜专 注诇 转砖讜讘讛 拽爪专讛, 讗讘诇 转住驻专 讗讬讱 拽讬讘诇转 讗转 讛讛讞诇讟讛, " + text
72
- model = "mistralai/Mistral-Nemo-Instruct-2407"
73
  elif language == "english":
74
  content = "keep it short but tell your decision making process, " + text
75
- model = "mistralai/Mistral-Nemo-Instruct-2407"
76
  else:
77
  return "Sorry, I only support Hebrew and English."
78
 
@@ -80,7 +80,7 @@ def generate_response(text):
80
 
81
  try:
82
  completion = client.chat.completions.create(
83
- model=model,
84
  messages=messages,
85
  max_tokens=2048,
86
  temperature=0.5,
 
2
  import logging
3
  from fastapi import FastAPI, Request
4
  import subprocess
5
+ from huggingface_hub import InferenceClient, login #, configure_http_backend, get_session
6
  import langid
7
+ # import requests
8
 
9
 
10
+ # # Create a factory function that returns a requests.Session object
11
+ # def backend_factory() -> requests.Session:
12
+ # session = requests.Session()
13
+ # # session.proxies = {"http": "http://your-proxy-host:your-proxy-port",
14
+ # # "https": "http://your-proxy-host:your-proxy-port"}
15
+ # return session
16
 
17
+ # # Set our custom backend factory as the default HTTP backend
18
+ # configure_http_backend(backend_factory=backend_factory)
19
 
20
+ # # For debugging
21
+ # session = get_session()
22
+ # print("Configured session:", session)
23
 
24
  # Configure logging
25
  logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s", level=logging.INFO)
 
69
  if language == "hebrew":
70
  # Hebrew prompt: answer shortly but explain your decision-making process
71
  content = "转砖诪讜专 注诇 转砖讜讘讛 拽爪专讛, 讗讘诇 转住驻专 讗讬讱 拽讬讘诇转 讗转 讛讛讞诇讟讛, " + text
72
+ #model = "mistralai/Mistral-Nemo-Instruct-2407"
73
  elif language == "english":
74
  content = "keep it short but tell your decision making process, " + text
75
+ # model = "mistralai/Mistral-Nemo-Instruct-2407"
76
  else:
77
  return "Sorry, I only support Hebrew and English."
78
 
 
80
 
81
  try:
82
  completion = client.chat.completions.create(
83
+ #model=model,
84
  messages=messages,
85
  max_tokens=2048,
86
  temperature=0.5,