Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,33 +31,33 @@ class GeminiLLM(LLM):
|
|
31 |
return "google-gemini-llm"
|
32 |
|
33 |
def _make_request(self, api_key: str, prompt: str) -> requests.Response:
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
"
|
51 |
-
{"text": full_prompt}
|
52 |
-
]
|
53 |
}
|
54 |
-
],
|
55 |
-
"generationConfig": {
|
56 |
-
"temperature": self.temperature
|
57 |
}
|
58 |
-
|
59 |
-
|
60 |
-
return requests.post(url, headers=headers, json=data)
|
61 |
|
62 |
|
63 |
|
|
|
31 |
return "google-gemini-llm"
|
32 |
|
33 |
def _make_request(self, api_key: str, prompt: str) -> requests.Response:
|
34 |
+
url = f"https://generativelanguage.googleapis.com/v1beta/models/{self.model_name}:generateContent"
|
35 |
+
headers = {
|
36 |
+
"Content-Type": "application/json",
|
37 |
+
"X-goog-api-key": api_key
|
38 |
+
}
|
39 |
+
|
40 |
+
full_prompt = (
|
41 |
+
"You are an agent. Please respond concisely only with the answer, "
|
42 |
+
"no extra explanations.\n\n"
|
43 |
+
f"Question: {prompt}"
|
44 |
+
)
|
45 |
|
46 |
+
data = {
|
47 |
+
"contents": [
|
48 |
+
{
|
49 |
+
"role": "user",
|
50 |
+
"parts": [
|
51 |
+
{"text": full_prompt}
|
52 |
+
]
|
53 |
+
}
|
54 |
+
],
|
55 |
+
"generationConfig": {
|
56 |
+
"temperature": self.temperature
|
|
|
|
|
57 |
}
|
|
|
|
|
|
|
58 |
}
|
59 |
+
|
60 |
+
return requests.post(url, headers=headers, json=data)
|
|
|
61 |
|
62 |
|
63 |
|