Spaces:
Runtime error
Runtime error
simpler test
Browse files
app.py
CHANGED
|
@@ -1,54 +1,62 @@
|
|
| 1 |
-
import os
|
| 2 |
import gradio as gr
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
# Creating the Gradio interface
|
| 33 |
-
with gr.Blocks() as demo:
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
if __name__ == "__main__":
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def greet(name):
|
| 4 |
+
return "Hello " + name + "!!"
|
| 5 |
+
|
| 6 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
+
iface.launch()
|
| 8 |
+
|
| 9 |
+
# import os
|
| 10 |
+
# import gradio as gr
|
| 11 |
+
# import openai
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# user_db = {
|
| 15 |
+
# os.environ["username"]: os.environ["password"],
|
| 16 |
+
# }
|
| 17 |
+
|
| 18 |
+
# # Assistant Creation function
|
| 19 |
+
# def create_assistant_json(uploaded_file, assistant_name, assistant_message):
|
| 20 |
+
# client = openai.OpenAI(api_key=os.environ["API_TOKEN"])
|
| 21 |
+
# # Check if a file was uploaded
|
| 22 |
+
# print(uploaded_file)
|
| 23 |
+
# df = open(uploaded_file, "rb")
|
| 24 |
+
# file = client.files.create(file=df,
|
| 25 |
+
# purpose='assistants')
|
| 26 |
+
|
| 27 |
+
# assistant = client.beta.assistants.create(
|
| 28 |
+
# name=assistant_name,
|
| 29 |
+
# instructions=assistant_message,
|
| 30 |
+
# model="gpt-4-0125-preview",
|
| 31 |
+
# tools=[
|
| 32 |
+
# {
|
| 33 |
+
# "type": "retrieval" # This adds the knowledge base as a tool
|
| 34 |
+
# }
|
| 35 |
+
# ],
|
| 36 |
+
# file_ids=[file.id])
|
| 37 |
|
| 38 |
+
# return assistant.id
|
| 39 |
+
|
| 40 |
+
# # Creating the Gradio interface
|
| 41 |
+
# with gr.Blocks() as demo:
|
| 42 |
+
# gr.Markdown("## To create an OpenAI Assistant please fill in the following sections. Upload a file to give the Assistant knowledge and a focus on something outside of it's normal training. Then add an assistant name and message. The Assistant message should guide the model into in a role. An example would be, You are a helpful Asssitant who is knowledgable in the field of...")
|
| 43 |
+
# gr.Markdown("## After creating the ID head to [OpenAI_Assistant_Chat](https://huggingface.co/spaces/jadend/OpenAI_Assistant_Chat).")
|
| 44 |
+
# with gr.Row():
|
| 45 |
+
# file_input = gr.File(label="Upload your file", type="filepath")
|
| 46 |
+
# assistant_name = gr.Textbox(label="The Assistant's Name")
|
| 47 |
+
# assistant_message = gr.Textbox(label="Assistant Message")
|
| 48 |
+
# generate_button = gr.Button("Generate Your Assistant ID")
|
| 49 |
+
# output_id = gr.Textbox(label="Your Asssistant ID", value="")
|
| 50 |
|
| 51 |
+
# generate_button.click(
|
| 52 |
+
# fn=create_assistant_json,
|
| 53 |
+
# inputs=[file_input, assistant_name, assistant_message],
|
| 54 |
+
# outputs=output_id
|
| 55 |
+
# )
|
| 56 |
+
|
| 57 |
+
# if __name__ == "__main__":
|
| 58 |
+
# demo.launch(#enable_queue=False,
|
| 59 |
+
# # Creates an auth screen
|
| 60 |
+
# auth=lambda u, p: user_db.get(u) == p,
|
| 61 |
+
# auth_message="Welcome! Enter a Username and Password"
|
| 62 |
+
# ).queue()
|