Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor tongyi models #3496

Merged
merged 9 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions api/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

from werkzeug.exceptions import Unauthorized

if not os.environ.get("DEBUG") or os.environ.get("DEBUG").lower() != 'true':
from gevent import monkey

Expand All @@ -11,10 +9,6 @@

grpc.experimental.gevent.init_gevent()

import langchain

langchain.verbose = True

import json
import logging
import threading
Expand All @@ -24,6 +18,7 @@
from flask import Flask, Response, request
from flask_cors import CORS

from werkzeug.exceptions import Unauthorized
from commands import register_commands
from config import CloudEditionConfig, Config
from extensions import (
Expand Down
3 changes: 3 additions & 0 deletions api/core/app/apps/advanced_chat/app_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import threading
import uuid
from collections.abc import Generator
Expand Down Expand Up @@ -189,6 +190,8 @@ def _generate_worker(self, flask_app: Flask,
logger.exception("Validation Error when generating")
queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER)
except (ValueError, InvokeError) as e:
if os.environ.get("DEBUG") and os.environ.get("DEBUG").lower() == 'true':
logger.exception("Error when generating")
queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER)
except Exception as e:
logger.exception("Unknown Error when generating")
Expand Down
3 changes: 3 additions & 0 deletions api/core/app/apps/agent_chat/app_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import threading
import uuid
from collections.abc import Generator
Expand Down Expand Up @@ -198,6 +199,8 @@ def _generate_worker(self, flask_app: Flask,
logger.exception("Validation Error when generating")
queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER)
except (ValueError, InvokeError) as e:
if os.environ.get("DEBUG") and os.environ.get("DEBUG").lower() == 'true':
logger.exception("Error when generating")
queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER)
except Exception as e:
logger.exception("Unknown Error when generating")
Expand Down
3 changes: 3 additions & 0 deletions api/core/app/apps/chat/app_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import threading
import uuid
from collections.abc import Generator
Expand Down Expand Up @@ -195,6 +196,8 @@ def _generate_worker(self, flask_app: Flask,
logger.exception("Validation Error when generating")
queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER)
except (ValueError, InvokeError) as e:
if os.environ.get("DEBUG") and os.environ.get("DEBUG").lower() == 'true':
logger.exception("Error when generating")
queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER)
except Exception as e:
logger.exception("Unknown Error when generating")
Expand Down
3 changes: 3 additions & 0 deletions api/core/app/apps/completion/app_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import threading
import uuid
from collections.abc import Generator
Expand Down Expand Up @@ -184,6 +185,8 @@ def _generate_worker(self, flask_app: Flask,
logger.exception("Validation Error when generating")
queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER)
except (ValueError, InvokeError) as e:
if os.environ.get("DEBUG") and os.environ.get("DEBUG").lower() == 'true':
logger.exception("Error when generating")
queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER)
except Exception as e:
logger.exception("Unknown Error when generating")
Expand Down
3 changes: 3 additions & 0 deletions api/core/app/apps/workflow/app_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import threading
import uuid
from collections.abc import Generator
Expand Down Expand Up @@ -137,6 +138,8 @@ def _generate_worker(self, flask_app: Flask,
logger.exception("Validation Error when generating")
queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER)
except (ValueError, InvokeError) as e:
if os.environ.get("DEBUG") and os.environ.get("DEBUG").lower() == 'true':
logger.exception("Error when generating")
queue_manager.publish_error(e, PublishFrom.APPLICATION_MANAGER)
except Exception as e:
logger.exception("Unknown Error when generating")
Expand Down
2 changes: 1 addition & 1 deletion api/core/model_runtime/model_providers/cohere/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def _convert_tools(self, tools: list[PromptMessageTool]) -> list[Tool]:
parameter_definitions = {}
for p_key, p_val in properties.items():
required = False
if property in required_properties:
if p_key in required_properties:
required = True

desc = p_val['description']
Expand Down
4 changes: 2 additions & 2 deletions api/core/model_runtime/model_providers/ollama/ollama.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ model_credential_schema:
options:
- value: 'true'
label:
en_US: Yes
en_US: 'Yes'
zh_Hans: 是
- value: 'false'
label:
en_US: No
en_US: 'No'
zh_Hans: 否
82 changes: 0 additions & 82 deletions api/core/model_runtime/model_providers/tongyi/llm/_client.py

This file was deleted.

Loading
Loading