Spaces:
Running
Running
update
Browse files
.env
CHANGED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
DEEP_SEEK_API_KEY=
|
2 |
+
DEBUG=False
|
.gitignore
CHANGED
@@ -9,3 +9,4 @@ wheels/
|
|
9 |
# venv
|
10 |
.venv
|
11 |
.idea
|
|
|
|
9 |
# venv
|
10 |
.venv
|
11 |
.idea
|
12 |
+
.env.local
|
app.py
CHANGED
@@ -2,13 +2,14 @@ import gradio as gr
|
|
2 |
from langchain_openai import ChatOpenAI
|
3 |
from langchain_core.messages import HumanMessage, AIMessage
|
4 |
from llm import DeepSeekLLM
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
chat = ChatOpenAI(model="deepseek-chat", api_key=deep_seek_llm.api_key, base_url=deep_seek_llm.base_url)
|
9 |
|
10 |
|
11 |
-
def predict(message, history):
|
|
|
12 |
history_messages = []
|
13 |
for human, assistant in history:
|
14 |
history_messages.append(HumanMessage(content=human))
|
@@ -21,38 +22,37 @@ def predict(message, history):
|
|
21 |
yield response_message
|
22 |
|
23 |
|
24 |
-
|
25 |
-
.
|
26 |
-
# min-height: calc(100vh - 300px);
|
27 |
-
}
|
28 |
-
"""
|
29 |
-
|
30 |
-
with gr.Blocks(css=css) as app:
|
31 |
-
with gr.Tab('Chat'):
|
32 |
with gr.Row():
|
33 |
with gr.Column(scale=2, min_width=600):
|
34 |
-
gr.ChatInterface(
|
35 |
predict,
|
36 |
multimodal=True,
|
37 |
chatbot=gr.Chatbot(elem_id="chatbot", height=600),
|
38 |
textbox=gr.MultimodalTextbox(),
|
39 |
-
|
40 |
-
|
41 |
-
with gr.Accordion('Select Model', open=True):
|
42 |
-
with gr.Column():
|
43 |
-
gr.Dropdown(
|
44 |
-
choices=deep_seek_llm.support_models,
|
45 |
-
type="value",
|
46 |
-
label="Model",
|
47 |
-
key="model",
|
48 |
-
)
|
49 |
gr.Slider(
|
50 |
minimum=0.0,
|
51 |
maximum=1.0,
|
52 |
step=0.1,
|
53 |
label="Temperature",
|
54 |
key="temperature",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
)
|
|
|
|
|
|
|
|
|
|
|
56 |
gr.Number(
|
57 |
minimum=1024,
|
58 |
maximum=1024 * 20,
|
@@ -62,7 +62,7 @@ with gr.Blocks(css=css) as app:
|
|
62 |
key="max_tokens",
|
63 |
)
|
64 |
|
65 |
-
with gr.Tab('
|
66 |
with gr.Row():
|
67 |
with gr.Column(scale=2, min_width=600):
|
68 |
gr.Image(label="Input Image")
|
@@ -70,4 +70,4 @@ with gr.Blocks(css=css) as app:
|
|
70 |
gr.Textbox(label="LoRA")
|
71 |
|
72 |
|
73 |
-
app.launch(debug=
|
|
|
2 |
from langchain_openai import ChatOpenAI
|
3 |
from langchain_core.messages import HumanMessage, AIMessage
|
4 |
from llm import DeepSeekLLM
|
5 |
+
from config import settings
|
6 |
|
7 |
+
deep_seek_llm = DeepSeekLLM(api_key=settings.deep_seek_api_key)
|
8 |
+
chat = ChatOpenAI(model=deep_seek_llm.default_model, api_key=deep_seek_llm.api_key, base_url=deep_seek_llm.base_url)
|
|
|
9 |
|
10 |
|
11 |
+
def predict(message, history, model: str, temperature: float, max_tokens: int):
|
12 |
+
print('???model', model, temperature, max_tokens)
|
13 |
history_messages = []
|
14 |
for human, assistant in history:
|
15 |
history_messages.append(HumanMessage(content=human))
|
|
|
22 |
yield response_message
|
23 |
|
24 |
|
25 |
+
with gr.Blocks() as app:
|
26 |
+
with gr.Tab('聊天'):
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
with gr.Row():
|
28 |
with gr.Column(scale=2, min_width=600):
|
29 |
+
chatbot = gr.ChatInterface(
|
30 |
predict,
|
31 |
multimodal=True,
|
32 |
chatbot=gr.Chatbot(elem_id="chatbot", height=600),
|
33 |
textbox=gr.MultimodalTextbox(),
|
34 |
+
additional_inputs=[
|
35 |
+
gr.Dropdown(choices=deep_seek_llm.support_models, label='模型'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
gr.Slider(
|
37 |
minimum=0.0,
|
38 |
maximum=1.0,
|
39 |
step=0.1,
|
40 |
label="Temperature",
|
41 |
key="temperature",
|
42 |
+
),
|
43 |
+
gr.Number(
|
44 |
+
minimum=1024,
|
45 |
+
maximum=1024 * 20,
|
46 |
+
step=128,
|
47 |
+
value=4096,
|
48 |
+
label="Max Tokens",
|
49 |
+
key="max_tokens",
|
50 |
)
|
51 |
+
],
|
52 |
+
)
|
53 |
+
with gr.Column(scale=1, min_width=300):
|
54 |
+
with gr.Accordion('Select Model', open=True):
|
55 |
+
with gr.Column():
|
56 |
gr.Number(
|
57 |
minimum=1024,
|
58 |
maximum=1024 * 20,
|
|
|
62 |
key="max_tokens",
|
63 |
)
|
64 |
|
65 |
+
with gr.Tab('画图'):
|
66 |
with gr.Row():
|
67 |
with gr.Column(scale=2, min_width=600):
|
68 |
gr.Image(label="Input Image")
|
|
|
70 |
gr.Textbox(label="LoRA")
|
71 |
|
72 |
|
73 |
+
app.launch(debug=settings.debug)
|
config.py
CHANGED
@@ -1,17 +1,12 @@
|
|
1 |
-
from typing import Any, Callable, Set
|
2 |
-
|
3 |
-
from pydantic import (
|
4 |
-
AliasChoices,
|
5 |
-
AmqpDsn,
|
6 |
-
BaseModel,
|
7 |
-
Field,
|
8 |
-
ImportString,
|
9 |
-
PostgresDsn,
|
10 |
-
RedisDsn,
|
11 |
-
)
|
12 |
-
|
13 |
from pydantic_settings import BaseSettings, SettingsConfigDict
|
14 |
|
15 |
|
16 |
class Settings(BaseSettings):
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from pydantic_settings import BaseSettings, SettingsConfigDict
|
2 |
|
3 |
|
4 |
class Settings(BaseSettings):
|
5 |
+
deep_seek_api_key: str
|
6 |
+
debug: bool
|
7 |
+
|
8 |
+
model_config = SettingsConfigDict(env_file=('.env', '.env.local'), env_file_encoding='utf-8')
|
9 |
+
|
10 |
+
|
11 |
+
settings = Settings()
|
12 |
+
|