fix: align venice/chat.py with gitea/dev.py patterns #2
@@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
title: Venice.ai Chat
|
title: Venice.ai Chat
|
||||||
author: Jeff Smith
|
author: Jeff Smith
|
||||||
version: 1.4.0
|
version: 1.3.1
|
||||||
license: MIT
|
license: MIT
|
||||||
required_open_webui_version: 0.6.0
|
required_open_webui_version: 0.6.0
|
||||||
requirements: httpx, pydantic
|
requirements: httpx, pydantic
|
||||||
@@ -18,11 +18,10 @@ description: |
|
|||||||
|
|
||||||
Use venice_info/list_models("text") to discover available models.
|
Use venice_info/list_models("text") to discover available models.
|
||||||
changelog:
|
changelog:
|
||||||
1.4.0:
|
1.3.1:
|
||||||
- Added VeniceChat namespace class for helper functions to avoid method collisions
|
- Added VeniceChat namespace class for helper functions to avoid method collisions
|
||||||
- Moved _get_api_key, _truncate, _format_error to VeniceChat namespace
|
- Moved _get_api_key, _truncate, _format_error to VeniceChat namespace
|
||||||
- Prevents Open WebUI framework introspection method name collisions
|
- Prevents Open WebUI framework introspection method name collisions
|
||||||
1.3.0:
|
|
||||||
- Fixed UserValves access pattern for per-user API keys
|
- Fixed UserValves access pattern for per-user API keys
|
||||||
- Added __request__ parameter handling for zero-config API calls
|
- Added __request__ parameter handling for zero-config API calls
|
||||||
- Enhanced __init__ for framework-driven configuration injection
|
- Enhanced __init__ for framework-driven configuration injection
|
||||||
@@ -52,7 +51,9 @@ class VeniceChat:
|
|||||||
# Check __user__ parameter first (for direct method calls)
|
# Check __user__ parameter first (for direct method calls)
|
||||||
if __user__ and "valves" in __user__:
|
if __user__ and "valves" in __user__:
|
||||||
user_valves_dict = __user__.get("valves")
|
user_valves_dict = __user__.get("valves")
|
||||||
if isinstance(user_valves_dict, dict) and user_valves_dict.get("VENICE_API_KEY"):
|
if isinstance(user_valves_dict, dict) and user_valves_dict.get(
|
||||||
|
"VENICE_API_KEY"
|
||||||
|
):
|
||||||
return user_valves_dict["VENICE_API_KEY"]
|
return user_valves_dict["VENICE_API_KEY"]
|
||||||
|
|
||||||
# Fall back to UserValves instance
|
# Fall back to UserValves instance
|
||||||
@@ -598,7 +599,9 @@ class Tools:
|
|||||||
return VeniceChat.truncate("\n".join(lines), self.valves.MAX_RESPONSE_SIZE)
|
return VeniceChat.truncate("\n".join(lines), self.valves.MAX_RESPONSE_SIZE)
|
||||||
|
|
||||||
except httpx.HTTPStatusError as e:
|
except httpx.HTTPStatusError as e:
|
||||||
error_msg = VeniceChat.format_error(e, f"conversation with {resolved_model}")
|
error_msg = VeniceChat.format_error(
|
||||||
|
e, f"conversation with {resolved_model}"
|
||||||
|
)
|
||||||
if __event_emitter__:
|
if __event_emitter__:
|
||||||
await __event_emitter__({"type": "status", "data": {"done": True}})
|
await __event_emitter__({"type": "status", "data": {"done": True}})
|
||||||
return f"Error: {error_msg}"
|
return f"Error: {error_msg}"
|
||||||
@@ -775,8 +778,13 @@ class Tools:
|
|||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"model": resolved_model,
|
"model": resolved_model,
|
||||||
"messages": [{"role": "user",}],
|
"messages": [
|
||||||
"temperature": 0.3, "content": query # Lower for factual responses
|
{
|
||||||
|
"role": "user",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"temperature": 0.3,
|
||||||
|
"content": query, # Lower for factual responses
|
||||||
"max_tokens": 2048,
|
"max_tokens": 2048,
|
||||||
"stream": False,
|
"stream": False,
|
||||||
"venice_parameters": {
|
"venice_parameters": {
|
||||||
|
|||||||
Reference in New Issue
Block a user