workspace working

This commit is contained in:
2026-01-12 22:31:11 +08:00
parent 2738a822d1
commit 370fe6368a
149 changed files with 4648 additions and 660 deletions

View File

@@ -1,27 +1,33 @@
import os
from dotenv import load_dotenv
load_dotenv()
import asyncio
import aiohttp
import json
print('Testing environment variables:')
print(f'OPENAI_API_KEY: {os.getenv("OPENAI_API_KEY")[:20]}...' if os.getenv('OPENAI_API_KEY') else 'OPENAI_API_KEY not set')
print(f'OPENAI_API_BASE: {os.getenv("OPENAI_API_BASE")}')
print(f'LLM_BINDING_API_KEY: {os.getenv("LLM_BINDING_API_KEY")[:20]}...' if os.getenv('LLM_BINDING_API_KEY') else 'LLM_BINDING_API_KEY not set')
print(f'LLM_BINDING_HOST: {os.getenv("LLM_BINDING_HOST")}')
async def test_search():
url = "http://localhost:3015/search"
headers = {
"Content-Type": "application/json",
"X-Workspace": "test1",
"X-API-Key": "jleu1212"
}
data = {
"query": "what is the minimum safe working distance",
"mode": "mix",
"return_raw_data": True,
"use_keywords": False
}
async with aiohttp.ClientSession() as session:
async with session.post(url, headers=headers, json=data) as resp:
print(f"Status: {resp.status}")
if resp.status == 200:
result = await resp.json()
print(json.dumps(result, indent=2))
else:
text = await resp.text()
print(f"Error: {text}")
return resp.status
# Test the OpenAI client with the current configuration
from openai import OpenAI
async def main():
await test_search()
client = OpenAI(
api_key=os.getenv('OPENAI_API_KEY'),
base_url=os.getenv('OPENAI_API_BASE')
)
try:
response = client.chat.completions.create(
model='deepseek-chat',
messages=[{'role': 'user', 'content': 'Hello, test'}],
max_tokens=10
)
print(f'Success! Response: {response.choices[0].message.content}')
except Exception as e:
print(f'Error: {e}')
if __name__ == "__main__":
asyncio.run(main())