fudii0921 commited on
Commit
c1aaf65
·
verified ·
1 Parent(s): ac1de0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -3
app.py CHANGED
@@ -4,6 +4,7 @@ from huggingface_hub import list_models
4
  import os
5
  from dotenv import load_dotenv
6
  import requests
 
7
 
8
  load_dotenv(verbose=True)
9
  groqkey = os.environ.get("GROQ_API_KEY")
@@ -46,13 +47,13 @@ def list_private_models(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthTo
46
  # if the user is not logged in, oauth_token will be None
47
  gr.Textbox(oauth_token)
48
  if oauth_token is None:
49
- return "Please log in to list private models.", gr.update(visible=False), gr.update(visible=False)
50
  #models = [
51
  #f"{model.id} ({'private' if model.private else 'public'})"
52
  #for model in list_models(author=profile.username, token=oauth_token.token)
53
  #]
54
  #return "Models:\n\n" + "\n - ".join(models) + ".", gr.update(visible=True)
55
- return profile.username, gr.update(visible=True), gr.update(visible=True)
56
 
57
 
58
  def process_eprag(prompt):
@@ -65,6 +66,23 @@ def process_eprag(prompt):
65
  return rtn
66
 
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  with gr.Blocks() as agentic:
69
  gr.Markdown(
70
  "# Gradio OAuth Space for Agentic RAG"
@@ -105,7 +123,25 @@ with gr.Blocks() as agentic:
105
  inputs=[eprag_input],
106
  outputs=[eprag_output]
107
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
- agentic.load(list_private_models, inputs=None, outputs=[m2, tab_llm, tab_eprag])
110
 
111
  agentic.launch()
 
4
  import os
5
  from dotenv import load_dotenv
6
  import requests
7
+ import json
8
 
9
  load_dotenv(verbose=True)
10
  groqkey = os.environ.get("GROQ_API_KEY")
 
47
  # if the user is not logged in, oauth_token will be None
48
  gr.Textbox(oauth_token)
49
  if oauth_token is None:
50
+ return "Please log in to list private models.", gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
51
  #models = [
52
  #f"{model.id} ({'private' if model.private else 'public'})"
53
  #for model in list_models(author=profile.username, token=oauth_token.token)
54
  #]
55
  #return "Models:\n\n" + "\n - ".join(models) + ".", gr.update(visible=True)
56
+ return profile.username, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
57
 
58
 
59
  def process_eprag(prompt):
 
66
  return rtn
67
 
68
 
69
+ def process_agent(prompt):
70
+ if prompt == "":
71
+ return "プロンプトを入力してください。", "プロンプトは必須です。"
72
+ else:
73
+ url = 'https://www.ryhintl.com/crewai/autogen?qry='+prompt
74
+ res = requests.get(url)
75
+ rtn = res.content.decode('utf-8')
76
+
77
+ parsed_data = json.loads(rtn)
78
+ content_list = [entry['content'] for entry in parsed_data['chat_history']]
79
+
80
+ for content in content_list:
81
+ mycontent = content
82
+
83
+ return mycontent
84
+
85
+
86
  with gr.Blocks() as agentic:
87
  gr.Markdown(
88
  "# Gradio OAuth Space for Agentic RAG"
 
123
  inputs=[eprag_input],
124
  outputs=[eprag_output]
125
  )
126
+
127
+ with gr.Tab("AGENT", visible=False) as tab_agentic:
128
+
129
+
130
+ gr.Markdown("# 🗞️ AGENTIC AUTOGEN")
131
+
132
+ with gr.Row():
133
+ agent_input = gr.Textbox(label="プロンプト", type="text")
134
+
135
+ with gr.Row():
136
+ agent_output = gr.Textbox(label="Agentアシスタントの応答")
137
+
138
+ submit_button = gr.Button("AGENTICプロセス", variant="primary")
139
+ submit_button.click(
140
+ process_agent,
141
+ inputs=[agent_input],
142
+ outputs=[agent_output]
143
+ )
144
 
145
+ agentic.load(list_private_models, inputs=None, outputs=[m2, tab_llm, tab_eprag, tab_agentic])
146
 
147
  agentic.launch()