Spaces:
Runtime error
Runtime error
File size: 2,475 Bytes
4d5f444 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# DEPRECATED: This file has been replaced by gemini_chat_model.py
# Please use GeminiChatModel instead of Gaio for LLM integration
import os
import requests
class Gaio:
def __init__(self, api_key, api_url):
self.api_key = api_key
self.api_url = api_url
def InvokeGaio(self, userPrompt):
payload = {
"model": "azure/gemini-2.5-pro",
"messages": [
{
"role": "user",
"content": userPrompt
}
],
"temperature": 0.00,
"max_tokens": 100000,
"stream": False
}
headers = {
"Authorization": f"Bearer {self.api_key}",
"Content-Type": "application/json"
}
# Make the POST request
response = requests.post(
self.api_url,
headers=headers,
json=payload,
timeout=30
)
# Parse the JSON response
result = response.json()
message = result["choices"][0]["message"]["content"]
return message
def main():
"""Test Gaio with a simple question and verify the answer."""
print("Testing Gaio with a simple math question...")
# Get API credentials from environment variables
api_key = os.getenv("GAIO_API_TOKEN")
api_url = os.getenv("GAIO_URL")
if not api_key or not api_url:
print("❌ Test failed: Missing environment variables.")
print("Please set the following environment variables:")
print("- GAIO_API_TOKEN: Your API token")
print("- GAIO_URL: The API URL")
return
try:
# Create Gaio instance
gaio = Gaio(api_key, api_url)
# Test with the specific question
test_question = "How much is 2 + 2 ? Only answer with the response number and nothing else."
print(f"\nQuestion: {test_question}")
# Get the answer
answer = gaio.InvokeGaio(test_question)
print(f"Answer: '{answer}'")
# Check if the answer is exactly "4"
answer_stripped = answer.strip()
if answer_stripped == "4":
print("✅ Test passed! The answer is exactly '4'.")
else:
print(f"❌ Test failed. Expected '4', but got '{answer_stripped}'.")
except Exception as e:
print(f"❌ Test failed with error: {e}")
if __name__ == "__main__":
main() |