Spaces:
Sleeping
Sleeping
acecalisto3
commited on
Commit
•
6719397
1
Parent(s):
2ea7ddc
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import os
|
4 |
-
import sys
|
5 |
import pickle
|
6 |
-
import json
|
7 |
|
8 |
st.title("CODEFUSSION ☄")
|
9 |
|
@@ -72,6 +70,15 @@ class DataRetrievalTool(Tool):
|
|
72 |
source = arguments.get("source", "https://example.com/data")
|
73 |
return {"output": f"Data from {source}"}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
class CodeExecutionTool(Tool):
|
76 |
def __init__(self):
|
77 |
super().__init__("Code Execution", "Runs code snippets in various languages.")
|
@@ -155,7 +162,7 @@ class ImageAnalysisTool(Tool):
|
|
155 |
|
156 |
# --- Agent Pool ---
|
157 |
agent_pool = {
|
158 |
-
"IdeaIntake": Agent("IdeaIntake", "Idea Intake", [DataRetrievalTool(), CodeGenerationTool(),
|
159 |
"CodeBuilder": Agent("CodeBuilder", "Code Builder", [CodeGenerationTool(), CodeDebuggingTool(), CodeOptimizationTool()], knowledge_base=""),
|
160 |
"ImageCreator": Agent("ImageCreator", "Image Creator", [ImageGenerationTool(), ImageEditingTool()], knowledge_base=""),
|
161 |
}
|
@@ -347,7 +354,7 @@ if st.session_state.chat_state == "normal":
|
|
347 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
348 |
conversation_history = [(message["role"], message["content"]) for message in st.session_state.messages]
|
349 |
|
350 |
-
formated_text =
|
351 |
|
352 |
with st.chat_message("assistant"):
|
353 |
# Select the appropriate model based on the user's choice
|
@@ -421,7 +428,7 @@ for agent_name, agent in agent_pool.items():
|
|
421 |
|
422 |
st.subheader("Workflows")
|
423 |
st.write("**App Build**")
|
424 |
-
st.write(f""" Description: {AppBuildWorkflow().description}")
|
425 |
st.write("**Website Build**")
|
426 |
st.write(f""" Description: {WebsiteBuildWorkflow().description}""")
|
427 |
st.write("**Game Build**")
|
@@ -433,12 +440,12 @@ st.write(f""" Description: {DevSandboxWorkflow().description}""")
|
|
433 |
|
434 |
# --- Displaying Tool Definitions ---
|
435 |
st.subheader("Tool Definitions")
|
436 |
-
for tool_class in [CodeGenerationTool, DataRetrievalTool, CodeExecutionTool, CodeDebuggingTool, CodeSummarizationTool, CodeTranslationTool, CodeOptimizationTool, CodeDocumentationTool, ImageGenerationTool, ImageEditingTool, ImageAnalysisTool]:
|
437 |
tool = tool_class()
|
438 |
st.write(f"**{tool.name}**")
|
439 |
st.write(f" Description: {tool.description}")
|
440 |
-
|
441 |
# --- Displaying Example Output ---
|
|
|
442 |
st.subheader("Example Output")
|
443 |
code_generation_tool = CodeGenerationTool()
|
444 |
st.write(f"""Code Generation Tool Output: {code_generation_tool.run({'language': 'python', 'code': 'print('Hello, World!')'})}""")
|
|
|
1 |
import streamlit as st
|
2 |
from huggingface_hub import InferenceClient
|
3 |
import os
|
|
|
4 |
import pickle
|
|
|
5 |
|
6 |
st.title("CODEFUSSION ☄")
|
7 |
|
|
|
70 |
source = arguments.get("source", "https://example.com/data")
|
71 |
return {"output": f"Data from {source}"}
|
72 |
|
73 |
+
class TextGenerationTool(Tool):
|
74 |
+
def __init__(self):
|
75 |
+
super().__init__("Text Generation", "Generates human-like text based on a given prompt.")
|
76 |
+
|
77 |
+
def run(self, arguments):
|
78 |
+
# This is a simplified example, real implementation would use a text generation model
|
79 |
+
prompt = arguments.get("prompt", "Write a short story about a cat.")
|
80 |
+
return {"output": f"Generated text: {prompt}"}
|
81 |
+
|
82 |
class CodeExecutionTool(Tool):
|
83 |
def __init__(self):
|
84 |
super().__init__("Code Execution", "Runs code snippets in various languages.")
|
|
|
162 |
|
163 |
# --- Agent Pool ---
|
164 |
agent_pool = {
|
165 |
+
"IdeaIntake": Agent("IdeaIntake", "Idea Intake", [DataRetrievalTool(), CodeGenerationTool(), TextGenerationTool()], knowledge_base=""),
|
166 |
"CodeBuilder": Agent("CodeBuilder", "Code Builder", [CodeGenerationTool(), CodeDebuggingTool(), CodeOptimizationTool()], knowledge_base=""),
|
167 |
"ImageCreator": Agent("ImageCreator", "Image Creator", [ImageGenerationTool(), ImageEditingTool()], knowledge_base=""),
|
168 |
}
|
|
|
354 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
355 |
conversation_history = [(message["role"], message["content"]) for message in st.session_state.messages]
|
356 |
|
357 |
+
formated_text = format_prompt(prompt, conversation_history, custom_instruction)
|
358 |
|
359 |
with st.chat_message("assistant"):
|
360 |
# Select the appropriate model based on the user's choice
|
|
|
428 |
|
429 |
st.subheader("Workflows")
|
430 |
st.write("**App Build**")
|
431 |
+
st.write(f""" Description: {AppBuildWorkflow().description}""")
|
432 |
st.write("**Website Build**")
|
433 |
st.write(f""" Description: {WebsiteBuildWorkflow().description}""")
|
434 |
st.write("**Game Build**")
|
|
|
440 |
|
441 |
# --- Displaying Tool Definitions ---
|
442 |
st.subheader("Tool Definitions")
|
443 |
+
for tool_class in [CodeGenerationTool, DataRetrievalTool, CodeExecutionTool, CodeDebuggingTool, CodeSummarizationTool, CodeTranslationTool, CodeOptimizationTool, CodeDocumentationTool, ImageGenerationTool, ImageEditingTool, ImageAnalysisTool, TextGenerationTool]:
|
444 |
tool = tool_class()
|
445 |
st.write(f"**{tool.name}**")
|
446 |
st.write(f" Description: {tool.description}")
|
|
|
447 |
# --- Displaying Example Output ---
|
448 |
+
|
449 |
st.subheader("Example Output")
|
450 |
code_generation_tool = CodeGenerationTool()
|
451 |
st.write(f"""Code Generation Tool Output: {code_generation_tool.run({'language': 'python', 'code': 'print('Hello, World!')'})}""")
|