bstraehle commited on
Commit
ee3145e
·
verified ·
1 Parent(s): cdbf492

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -9
app.py CHANGED
@@ -8,7 +8,7 @@ lock = threading.Lock()
8
  os.environ["LANGCHAIN_PROJECT"] = "langgraph-multi-agent"
9
  os.environ["LANGCHAIN_TRACING_V2"] = "true"
10
 
11
- LLM = "gpt-4o"
12
 
13
  def invoke(openai_api_key, topic):
14
  if not openai_api_key:
@@ -22,13 +22,37 @@ def invoke(openai_api_key, topic):
22
  del os.environ["OPENAI_API_KEY"]
23
  return article
24
 
25
- gr.close_all()
 
26
 
27
- demo = gr.Interface(fn = invoke,
28
- inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
29
- gr.Textbox(label = "Topic", value=os.environ["TOPIC"], lines = 1)],
30
- outputs = [gr.Markdown(label = "Article", value=os.environ["OUTPUT"])],
31
- title = "Multi-Agent AI: Article Writing",
32
- description = os.environ["DESCRIPTION"])
33
 
34
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  os.environ["LANGCHAIN_PROJECT"] = "langgraph-multi-agent"
9
  os.environ["LANGCHAIN_TRACING_V2"] = "true"
10
 
11
+ LLM = "gpt-4.1"
12
 
13
  def invoke(openai_api_key, topic):
14
  if not openai_api_key:
 
22
  del os.environ["OPENAI_API_KEY"]
23
  return article
24
 
25
+ def clear():
26
+ return ""
27
 
28
+ gr.close_all()
 
 
 
 
 
29
 
30
+ with gr.Blocks() as assistant:
31
+ gr.Markdown("## Multi-Agent AI: Article Writing")
32
+ gr.Markdown(os.environ.get("DESCRIPTION"))
33
+
34
+ with gr.Row():
35
+ with gr.Column(scale=1):
36
+ with gr.Row():
37
+ openai_api_key = gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1)
38
+ topic = gr.Textbox(label = "Topic", value=os.environ["TOPIC"], lines = 1)
39
+ with gr.Row():
40
+ clear_btn = gr.ClearButton(
41
+ components=[openai_api_key, topic]
42
+ )
43
+ submit_btn = gr.Button("Submit", variant="primary")
44
+ with gr.Column(scale=3):
45
+ article = gr.Markdown(label = "Article", value=os.environ["OUTPUT"], line_breaks = True, sanitize_html = False)
46
+
47
+ clear_btn.click(
48
+ fn=clear,
49
+ outputs=article
50
+ )
51
+
52
+ submit_btn.click(
53
+ fn=invoke,
54
+ inputs=[openai_api_key, topic],
55
+ outputs=article
56
+ )
57
+
58
+ assistant.launch()