Spaces:
Runtime error
Runtime error
π³ fix(Dockerfile): change CMD from python app.py to uvicorn claude_space.app:gd to use Uvicorn as ASGI server
Browse files⨠feat(claude_space): add ai.py, app.py, const.py, settings.py for AI interaction and server setup
π§ chore(pyproject.toml): add isort to dependencies for better code formatting
- Dockerfile +1 -1
- ai.py β claude_space/ai.py +1 -1
- app.py β claude_space/app.py +8 -15
- const.py β claude_space/const.py +0 -0
- settings.py β claude_space/settings.py +0 -0
- poetry.lock +19 -1
- pyproject.toml +2 -1
Dockerfile
CHANGED
@@ -42,4 +42,4 @@ COPY . .
|
|
42 |
RUN poetry install
|
43 |
|
44 |
COPY . .
|
45 |
-
CMD ["
|
|
|
42 |
RUN poetry install
|
43 |
|
44 |
COPY . .
|
45 |
+
CMD ["uvicorn", "claude_space.app:gd", "--host", "0.0.0.0", "--port", "7860"]
|
ai.py β claude_space/ai.py
RENAMED
@@ -3,7 +3,7 @@ import os
|
|
3 |
import anthropic
|
4 |
from dotenv import load_dotenv
|
5 |
|
6 |
-
from settings import settings
|
7 |
|
8 |
load_dotenv()
|
9 |
|
|
|
3 |
import anthropic
|
4 |
from dotenv import load_dotenv
|
5 |
|
6 |
+
from claude_space.settings import settings
|
7 |
|
8 |
load_dotenv()
|
9 |
|
app.py β claude_space/app.py
RENAMED
@@ -4,10 +4,9 @@ import anthropic
|
|
4 |
import gradio as gr
|
5 |
from gradio.components import Checkbox, Dropdown, IOComponent, Textbox
|
6 |
|
7 |
-
from ai import AnthropicCustom
|
8 |
-
from const import ClaudeModels, ModelTokenLength, Prompts
|
9 |
|
10 |
-
# Define a global variable for the conversation history
|
11 |
conversation_history = ""
|
12 |
|
13 |
|
@@ -30,12 +29,10 @@ async def interact_with_ai(
|
|
30 |
prompt,
|
31 |
)
|
32 |
|
33 |
-
# Create an instance of the custom class
|
34 |
anth = AnthropicCustom(
|
35 |
api_key=token, model=model, max_tokens=token_length, prompt=prompt
|
36 |
)
|
37 |
|
38 |
-
# Create a generator to stream the response
|
39 |
response_accumulated = ""
|
40 |
async for response in anth.get_anthropic_response_async():
|
41 |
response_accumulated += response
|
@@ -69,12 +66,10 @@ async def chat_with_ai(
|
|
69 |
prompt,
|
70 |
)
|
71 |
|
72 |
-
# Create an instance of the custom class
|
73 |
anth = AnthropicCustom(
|
74 |
api_key=token, model=model, max_tokens=token_length, prompt=prompt
|
75 |
)
|
76 |
|
77 |
-
# Create a generator to stream the response
|
78 |
response_accumulated = ""
|
79 |
async for response in anth.get_anthropic_response_async():
|
80 |
response_accumulated += response
|
@@ -156,11 +151,9 @@ cface = gr.ChatInterface(
|
|
156 |
],
|
157 |
)
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
debug=True, share=False, server_name="0.0.0.0", server_port=7864
|
166 |
-
)
|
|
|
4 |
import gradio as gr
|
5 |
from gradio.components import Checkbox, Dropdown, IOComponent, Textbox
|
6 |
|
7 |
+
from claude_space.ai import AnthropicCustom
|
8 |
+
from claude_space.const import ClaudeModels, ModelTokenLength, Prompts
|
9 |
|
|
|
10 |
conversation_history = ""
|
11 |
|
12 |
|
|
|
29 |
prompt,
|
30 |
)
|
31 |
|
|
|
32 |
anth = AnthropicCustom(
|
33 |
api_key=token, model=model, max_tokens=token_length, prompt=prompt
|
34 |
)
|
35 |
|
|
|
36 |
response_accumulated = ""
|
37 |
async for response in anth.get_anthropic_response_async():
|
38 |
response_accumulated += response
|
|
|
66 |
prompt,
|
67 |
)
|
68 |
|
|
|
69 |
anth = AnthropicCustom(
|
70 |
api_key=token, model=model, max_tokens=token_length, prompt=prompt
|
71 |
)
|
72 |
|
|
|
73 |
response_accumulated = ""
|
74 |
async for response in anth.get_anthropic_response_async():
|
75 |
response_accumulated += response
|
|
|
151 |
],
|
152 |
)
|
153 |
|
154 |
+
gd = gr.TabbedInterface(
|
155 |
+
[iface, cface], tab_names=["Claude Space", "Claude Chat"], title="Claude Space"
|
156 |
+
)
|
157 |
+
gd.queue(concurrency_count=75, max_size=100).launch(
|
158 |
+
debug=True, share=False, server_name="0.0.0.0", server_port=7864
|
159 |
+
)
|
|
|
|
const.py β claude_space/const.py
RENAMED
File without changes
|
settings.py β claude_space/settings.py
RENAMED
File without changes
|
poetry.lock
CHANGED
@@ -710,6 +710,24 @@ files = [
|
|
710 |
docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"]
|
711 |
testing = ["pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-ruff"]
|
712 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
713 |
[[package]]
|
714 |
name = "jinja2"
|
715 |
version = "3.1.2"
|
@@ -2088,4 +2106,4 @@ files = [
|
|
2088 |
[metadata]
|
2089 |
lock-version = "2.0"
|
2090 |
python-versions = "^3.10"
|
2091 |
-
content-hash = "
|
|
|
710 |
docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"]
|
711 |
testing = ["pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-ruff"]
|
712 |
|
713 |
+
[[package]]
|
714 |
+
name = "isort"
|
715 |
+
version = "5.12.0"
|
716 |
+
description = "A Python utility / library to sort Python imports."
|
717 |
+
category = "main"
|
718 |
+
optional = false
|
719 |
+
python-versions = ">=3.8.0"
|
720 |
+
files = [
|
721 |
+
{file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"},
|
722 |
+
{file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"},
|
723 |
+
]
|
724 |
+
|
725 |
+
[package.extras]
|
726 |
+
colors = ["colorama (>=0.4.3)"]
|
727 |
+
pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"]
|
728 |
+
plugins = ["setuptools"]
|
729 |
+
requirements-deprecated-finder = ["pip-api", "pipreqs"]
|
730 |
+
|
731 |
[[package]]
|
732 |
name = "jinja2"
|
733 |
version = "3.1.2"
|
|
|
2106 |
[metadata]
|
2107 |
lock-version = "2.0"
|
2108 |
python-versions = "^3.10"
|
2109 |
+
content-hash = "e3fe706bdba166afe4c270fda457830aac712dfa274f9e6940ba7ef31f401be0"
|
pyproject.toml
CHANGED
@@ -14,6 +14,7 @@ gradio = "^3.41.2"
|
|
14 |
anthropic = "^0.3.10"
|
15 |
python-dotenv = "^1.0.0"
|
16 |
flake8 = "^6.1.0"
|
|
|
17 |
|
18 |
[tool.poetry.dev-dependencies]
|
19 |
pre-commit = "^2.15.0"
|
@@ -24,7 +25,7 @@ build-backend = "poetry.core.masonry.api"
|
|
24 |
|
25 |
[tool.isort]
|
26 |
profile = "black"
|
27 |
-
known_third_party = ["anthropic", "gradio"
|
28 |
|
29 |
[tool.black]
|
30 |
line-length = 88
|
|
|
14 |
anthropic = "^0.3.10"
|
15 |
python-dotenv = "^1.0.0"
|
16 |
flake8 = "^6.1.0"
|
17 |
+
isort = "^5.12.0"
|
18 |
|
19 |
[tool.poetry.dev-dependencies]
|
20 |
pre-commit = "^2.15.0"
|
|
|
25 |
|
26 |
[tool.isort]
|
27 |
profile = "black"
|
28 |
+
known_third_party = ["anthropic", "gradio"]
|
29 |
|
30 |
[tool.black]
|
31 |
line-length = 88
|