Spaces:
Running
on
Zero
Running
on
Zero
udpate
Browse files- README.md +6 -0
- command/interpreter.py +10 -0
- command/langchain.py +54 -0
- controllers/test +1 -0
- controllers/testfolder111111111 +1 -0
- controllers/testfolder12345 +1 -0
- controllers/testsystem +1 -0
- controllers/usersystem +1 -0
- gpt-engineer/Makefile +1 -1
- gpt_engenner.py +4 -0
- mysite/interpreter/process.py +1 -1
- requirements.txt +2 -1
- up.txt +0 -0
README.md
CHANGED
@@ -10,3 +10,9 @@ pinned: false
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
---
|
11 |
|
12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
13 |
+
for gpt-enginner
|
14 |
+
export OPENAI_API_BASE="https://api.groq.com/openai/v1"
|
15 |
+
export OPENAI_API_KEY="*************"
|
16 |
+
export MODEL_NAME="llama3-8b-8192"
|
17 |
+
export LOCAL_MODEL=true
|
18 |
+
for interpreter
|
command/interpreter.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# https://colab.research.google.com/drive/1Bg84yu7H7_3-gLi_9kq7dqQUBlY2gID8#scrollTo=GN-l2igNCwjt
|
2 |
+
from interpreter import interpreter
|
3 |
+
# 環境変数でOpenAI APIキーを保存および使用
|
4 |
+
interpreter.auto_run = True
|
5 |
+
#interpreter.llm.model = "huggingface/meta-llama/Meta-Llama-3-8B-Instruct"
|
6 |
+
#interpreter.llm.api_key = os.getenv("hf_token")
|
7 |
+
interpreter.llm.api_base = "https://api.groq.com/openai/v1"
|
8 |
+
interpreter.llm.api_key = os.getenv("apikey")
|
9 |
+
interpreter.llm.model = "Llama3-70b-8192"
|
10 |
+
interpreter.chat()
|
command/langchain.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
from langchain.chains import LLMChain
|
4 |
+
from langchain_core.prompts import (
|
5 |
+
ChatPromptTemplate,
|
6 |
+
HumanMessagePromptTemplate,
|
7 |
+
MessagesPlaceholder,
|
8 |
+
)
|
9 |
+
from langchain_core.messages import SystemMessage
|
10 |
+
from langchain.chains.conversation.memory import ConversationBufferWindowMemory
|
11 |
+
from langchain_groq import ChatGroq
|
12 |
+
|
13 |
+
|
14 |
+
# Get Groq API key
|
15 |
+
groq_api_key = os.getenv("apikey")
|
16 |
+
groq_chat = ChatGroq(groq_api_key=groq_api_key, model_name="llama3-70b-8192")
|
17 |
+
|
18 |
+
system_prompt = "あなたは便利なアシスタントです。"
|
19 |
+
conversational_memory_length = 5
|
20 |
+
|
21 |
+
memory = ConversationBufferWindowMemory(
|
22 |
+
k=conversational_memory_length, memory_key="chat_history", return_messages=True
|
23 |
+
)
|
24 |
+
|
25 |
+
while True:
|
26 |
+
user_question = input("質問を入力してください: ")
|
27 |
+
|
28 |
+
if user_question.lower() == "exit":
|
29 |
+
print("Goodbye!")
|
30 |
+
break
|
31 |
+
|
32 |
+
if user_question:
|
33 |
+
# Construct a chat prompt template using various components
|
34 |
+
prompt = ChatPromptTemplate.from_messages(
|
35 |
+
[
|
36 |
+
# 毎回必ず含まれるSystemプロンプトを追加
|
37 |
+
SystemMessage(content=system_prompt),
|
38 |
+
# ConversationBufferWindowMemoryをプロンプトに追加
|
39 |
+
MessagesPlaceholder(variable_name="chat_history"),
|
40 |
+
# ユーザーの入力をプロンプトに追加
|
41 |
+
HumanMessagePromptTemplate.from_template("{human_input}"),
|
42 |
+
]
|
43 |
+
)
|
44 |
+
|
45 |
+
conversation = LLMChain(
|
46 |
+
llm=groq_chat,
|
47 |
+
prompt=prompt,
|
48 |
+
verbose=False,
|
49 |
+
memory=memory,
|
50 |
+
)
|
51 |
+
response = conversation.predict(human_input=user_question)
|
52 |
+
|
53 |
+
print("User: ", user_question)
|
54 |
+
print("Assistant:", response)
|
controllers/test
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Subproject commit d7e6705d8d7fbd0f539e74b6354dfea0bff14c0f
|
controllers/testfolder111111111
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Subproject commit 5fd9bec5d1047157b1bee8098e616098a0141b52
|
controllers/testfolder12345
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Subproject commit c8aa2a301cbf1076465d24a834624a4826ff9ecd
|
controllers/testsystem
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Subproject commit 4db610bb927fa74c58a308e6a9e48bc26051ec5c
|
controllers/usersystem
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Subproject commit 95da06e4e4c0c258bbec44afdd4586b9399500f4
|
gpt-engineer/Makefile
CHANGED
@@ -46,7 +46,7 @@ farewell:
|
|
46 |
#Defines a target named run. This target will run GPT Engineer on the folder with the given name.
|
47 |
run:
|
48 |
@echo -e "$(COLOR_CYAN)Running GPT Engineer on $(COLOR_GREEN)$(name)$(COLOR_CYAN) folder...$(COLOR_RESET)" && \
|
49 |
-
poetry run gpt-engineer
|
50 |
|
51 |
# Counts the lines of code in the project
|
52 |
cloc:
|
|
|
46 |
#Defines a target named run. This target will run GPT Engineer on the folder with the given name.
|
47 |
run:
|
48 |
@echo -e "$(COLOR_CYAN)Running GPT Engineer on $(COLOR_GREEN)$(name)$(COLOR_CYAN) folder...$(COLOR_RESET)" && \
|
49 |
+
poetry run gpt-engineer /home/user/app/controllers/$(name) --model Llama3-70b-8192 --temperature 0.1
|
50 |
|
51 |
# Counts the lines of code in the project
|
52 |
cloc:
|
gpt_engenner.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from mysite.interpreter.process import no_process_file
|
2 |
+
|
3 |
+
|
4 |
+
no_process_file("ineのテストファイルの実行","testfolder12345")
|
mysite/interpreter/process.py
CHANGED
@@ -19,7 +19,7 @@ BASE_PATH = "/home/user/app/controllers/"
|
|
19 |
|
20 |
def set_environment_variables():
|
21 |
os.environ["OPENAI_API_BASE"] = "https://api.groq.com/openai/v1"
|
22 |
-
os.environ["OPENAI_API_KEY"] = "
|
23 |
os.environ["MODEL_NAME"] = "llama3-8b-8192"
|
24 |
os.environ["LOCAL_MODEL"] = "true"
|
25 |
|
|
|
19 |
|
20 |
def set_environment_variables():
|
21 |
os.environ["OPENAI_API_BASE"] = "https://api.groq.com/openai/v1"
|
22 |
+
os.environ["OPENAI_API_KEY"] = os.getenv("api_key")
|
23 |
os.environ["MODEL_NAME"] = "llama3-8b-8192"
|
24 |
os.environ["LOCAL_MODEL"] = "true"
|
25 |
|
requirements.txt
CHANGED
@@ -53,4 +53,5 @@ huggingface-hub
|
|
53 |
imageio[ffmpeg]
|
54 |
torch
|
55 |
torchvision
|
56 |
-
transformers
|
|
|
|
53 |
imageio[ffmpeg]
|
54 |
torch
|
55 |
torchvision
|
56 |
+
transformers
|
57 |
+
langchain_groq
|
up.txt
ADDED
File without changes
|