Spaces:
Paused
Paused
MEOW commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ logging.basicConfig(level=logging.INFO)
|
|
| 11 |
logger = logging.getLogger(__name__)
|
| 12 |
|
| 13 |
# Assuming xAI provides their endpoint for generating text
|
| 14 |
-
XAI_API_URL = "https://api.x.ai/v1/chat/completions"
|
| 15 |
|
| 16 |
# Custom LLM class for xAI
|
| 17 |
class XAILLM:
|
|
@@ -25,7 +25,7 @@ class XAILLM:
|
|
| 25 |
data = {
|
| 26 |
"model": "grok-beta", # Adjust model name as per xAI's API
|
| 27 |
"messages": [{"role": "user", "content": prompt}],
|
| 28 |
-
"stream":
|
| 29 |
}
|
| 30 |
response = requests.post(XAI_API_URL, headers=headers, json=data)
|
| 31 |
response.raise_for_status()
|
|
@@ -37,7 +37,7 @@ Settings.llm = XAILLM()
|
|
| 37 |
class XAIEmbedding:
|
| 38 |
def __init__(self):
|
| 39 |
self.api_key = os.getenv('XAI_API_KEY')
|
| 40 |
-
self.model_id = "v1"
|
| 41 |
|
| 42 |
def get_text_embedding(self, text):
|
| 43 |
headers = {
|
|
|
|
| 11 |
logger = logging.getLogger(__name__)
|
| 12 |
|
| 13 |
# Assuming xAI provides their endpoint for generating text
|
| 14 |
+
XAI_API_URL = "https://api.x.ai/v1/chat/completions"
|
| 15 |
|
| 16 |
# Custom LLM class for xAI
|
| 17 |
class XAILLM:
|
|
|
|
| 25 |
data = {
|
| 26 |
"model": "grok-beta", # Adjust model name as per xAI's API
|
| 27 |
"messages": [{"role": "user", "content": prompt}],
|
| 28 |
+
"stream": True # or True if you want streaming responses
|
| 29 |
}
|
| 30 |
response = requests.post(XAI_API_URL, headers=headers, json=data)
|
| 31 |
response.raise_for_status()
|
|
|
|
| 37 |
class XAIEmbedding:
|
| 38 |
def __init__(self):
|
| 39 |
self.api_key = os.getenv('XAI_API_KEY')
|
| 40 |
+
self.model_id = "v1"
|
| 41 |
|
| 42 |
def get_text_embedding(self, text):
|
| 43 |
headers = {
|