mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 05:39:12 +00:00
Align expected types to actual returned types by AI APIs, operator
This commit is contained in:
@@ -164,7 +164,7 @@ async def converse_anthropic(
|
|||||||
generated_asset_results: Dict[str, Dict] = {},
|
generated_asset_results: Dict[str, Dict] = {},
|
||||||
deepthought: Optional[bool] = False,
|
deepthought: Optional[bool] = False,
|
||||||
tracer: dict = {},
|
tracer: dict = {},
|
||||||
) -> AsyncGenerator[ResponseWithThought, None]:
|
) -> AsyncGenerator[str | ResponseWithThought, None]:
|
||||||
"""
|
"""
|
||||||
Converse with user using Anthropic's Claude
|
Converse with user using Anthropic's Claude
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ async def converse_openai(
|
|||||||
program_execution_context: List[str] = None,
|
program_execution_context: List[str] = None,
|
||||||
deepthought: Optional[bool] = False,
|
deepthought: Optional[bool] = False,
|
||||||
tracer: dict = {},
|
tracer: dict = {},
|
||||||
) -> AsyncGenerator[ResponseWithThought, None]:
|
) -> AsyncGenerator[str | ResponseWithThought, None]:
|
||||||
"""
|
"""
|
||||||
Converse with user using OpenAI's ChatGPT
|
Converse with user using OpenAI's ChatGPT
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from io import BytesIO
|
|||||||
from typing import Any, List
|
from typing import Any, List
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from openai import AzureOpenAI, OpenAI
|
from openai import AsyncAzureOpenAI, AsyncOpenAI
|
||||||
from openai.types.chat import ChatCompletion
|
from openai.types.chat import ChatCompletion
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ class GroundingAgentUitars:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
model_name: str,
|
model_name: str,
|
||||||
client: OpenAI | AzureOpenAI,
|
client: AsyncOpenAI | AsyncAzureOpenAI,
|
||||||
max_iterations=50,
|
max_iterations=50,
|
||||||
environment_type: Literal["computer", "web"] = "computer",
|
environment_type: Literal["computer", "web"] = "computer",
|
||||||
runtime_conf: dict = {
|
runtime_conf: dict = {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ async def update_chat_model(
|
|||||||
if chat_model is None:
|
if chat_model is None:
|
||||||
return Response(status_code=404, content=json.dumps({"status": "error", "message": "Chat model not found"}))
|
return Response(status_code=404, content=json.dumps({"status": "error", "message": "Chat model not found"}))
|
||||||
if not subscribed and chat_model.price_tier != PriceTier.FREE:
|
if not subscribed and chat_model.price_tier != PriceTier.FREE:
|
||||||
raise Response(
|
return Response(
|
||||||
status_code=403,
|
status_code=403,
|
||||||
content=json.dumps({"status": "error", "message": "Subscribe to switch to this chat model"}),
|
content=json.dumps({"status": "error", "message": "Subscribe to switch to this chat model"}),
|
||||||
)
|
)
|
||||||
@@ -108,7 +108,7 @@ async def update_voice_model(
|
|||||||
if voice_model is None:
|
if voice_model is None:
|
||||||
return Response(status_code=404, content=json.dumps({"status": "error", "message": "Voice model not found"}))
|
return Response(status_code=404, content=json.dumps({"status": "error", "message": "Voice model not found"}))
|
||||||
if not subscribed and voice_model.price_tier != PriceTier.FREE:
|
if not subscribed and voice_model.price_tier != PriceTier.FREE:
|
||||||
raise Response(
|
return Response(
|
||||||
status_code=403,
|
status_code=403,
|
||||||
content=json.dumps({"status": "error", "message": "Subscribe to switch to this voice model"}),
|
content=json.dumps({"status": "error", "message": "Subscribe to switch to this voice model"}),
|
||||||
)
|
)
|
||||||
@@ -143,7 +143,7 @@ async def update_paint_model(
|
|||||||
if image_model is None:
|
if image_model is None:
|
||||||
return Response(status_code=404, content=json.dumps({"status": "error", "message": "Image model not found"}))
|
return Response(status_code=404, content=json.dumps({"status": "error", "message": "Image model not found"}))
|
||||||
if not subscribed and image_model.price_tier != PriceTier.FREE:
|
if not subscribed and image_model.price_tier != PriceTier.FREE:
|
||||||
raise Response(
|
return Response(
|
||||||
status_code=403,
|
status_code=403,
|
||||||
content=json.dumps({"status": "error", "message": "Subscribe to switch to this image model"}),
|
content=json.dumps({"status": "error", "message": "Subscribe to switch to this image model"}),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user