kenken999 commited on
Commit
db8a475
1 Parent(s): 24e2188
Files changed (4) hide show
  1. app.py +14 -13
  2. index.html +10 -0
  3. sample.csv +6 -0
  4. static/index.html +29 -1
app.py CHANGED
@@ -267,7 +267,7 @@ def add_conversation(conversations, num_messages=4):
267
  messages.append(assistant_entry)
268
 
269
  # Set the environment variable.
270
- def chat_with_interpreter(message, history,a=None,b=None):#, openai_api_key):
271
  # Set the API key for the interpreter
272
  #interpreter.llm.api_key = openai_api_key
273
  if message == 'reset':
@@ -275,7 +275,7 @@ def chat_with_interpreter(message, history,a=None,b=None):#, openai_api_key):
275
  return "Interpreter reset", history
276
  output = ''
277
  full_response = ""
278
- add_conversation(history)
279
  user_entry = {"role": "user", "type": "message", "content": message}
280
  messages.append(user_entry)
281
  # Call interpreter.chat and capture the result
@@ -441,8 +441,8 @@ chatbot=gr.Chatbot(height=450, placeholder=PLACEHOLDER, label='Gradio ChatInterf
441
 
442
  with gr.Blocks(fill_height=True, css=css) as demo:
443
 
444
- gr.Markdown(DESCRIPTION)
445
- gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
446
  gr.ChatInterface(
447
  fn=chat_with_interpreter,
448
  chatbot=chatbot,
@@ -460,7 +460,7 @@ with gr.Blocks(fill_height=True, css=css) as demo:
460
  step=1,
461
  value=512,
462
  label="Max new tokens",
463
- render=False ),
464
  ],
465
  examples=[
466
  ['HTMLのサンプルを作成して'],
@@ -469,7 +469,7 @@ with gr.Blocks(fill_height=True, css=css) as demo:
469
  cache_examples=False,
470
  )
471
 
472
- gr.Markdown(LICENSE)
473
 
474
 
475
  # Gradio block
@@ -477,8 +477,8 @@ chatbot2=gr.Chatbot(height=450, placeholder=PLACEHOLDER, label='Gradio ChatInter
477
 
478
  with gr.Blocks(fill_height=True, css=css) as democ:
479
 
480
- gr.Markdown(DESCRIPTION)
481
- gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
482
  gr.ChatInterface(
483
  fn=completion,
484
  chatbot=chatbot2,
@@ -547,17 +547,18 @@ with gr.Blocks() as mark:
547
  #demo.launch()
548
  # キューを有効にする
549
  chat_interface.queue()
550
- tabs = gr.TabbedInterface([demo4,demo, create_ui(),democ,mark], ["Interpreter","AIで開発", "FineTuning","CHAT","AWS SERVERLESS SYSTEM"])
551
  tabs.queue()
552
  app.mount("/static", StaticFiles(directory="static", html=True), name="static")
553
- app = gr.mount_gradio_app(app, tabs, "/")#, gradio_api_url="http://localhost:7860/")
554
  # テンプレートファイルが格納されているディレクトリを指定
555
  templates = Jinja2Templates(directory="static")
556
 
557
- #@app.get("/")
558
- #def get_some_page(request: Request):
 
559
  # テンプレートを使用してHTMLを生成し、返す
560
- # return templates.TemplateResponse("index.html", {"request": request})
561
  # FastAPIのエンドポイントを定義
562
  @app.get("/groq")
563
  def hello_world():
 
267
  messages.append(assistant_entry)
268
 
269
  # Set the environment variable.
270
+ def chat_with_interpreter(message, history,a=None,b=None,c=None,d=None):#, openai_api_key):
271
  # Set the API key for the interpreter
272
  #interpreter.llm.api_key = openai_api_key
273
  if message == 'reset':
 
275
  return "Interpreter reset", history
276
  output = ''
277
  full_response = ""
278
+ add_conversation(history,20)
279
  user_entry = {"role": "user", "type": "message", "content": message}
280
  messages.append(user_entry)
281
  # Call interpreter.chat and capture the result
 
441
 
442
  with gr.Blocks(fill_height=True, css=css) as demo:
443
 
444
+ #gr.Markdown(DESCRIPTION)
445
+ #gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
446
  gr.ChatInterface(
447
  fn=chat_with_interpreter,
448
  chatbot=chatbot,
 
460
  step=1,
461
  value=512,
462
  label="Max new tokens",
463
+ render=False ),
464
  ],
465
  examples=[
466
  ['HTMLのサンプルを作成して'],
 
469
  cache_examples=False,
470
  )
471
 
472
+ #gr.Markdown(LICENSE)
473
 
474
 
475
  # Gradio block
 
477
 
478
  with gr.Blocks(fill_height=True, css=css) as democ:
479
 
480
+ #gr.Markdown(DESCRIPTION)
481
+ #gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
482
  gr.ChatInterface(
483
  fn=completion,
484
  chatbot=chatbot2,
 
547
  #demo.launch()
548
  # キューを有効にする
549
  chat_interface.queue()
550
+ tabs = gr.TabbedInterface([demo, create_ui(),democ,mark], ["AIで開発", "FineTuning","CHAT","AWS SERVERLESS SYSTEM"])
551
  tabs.queue()
552
  app.mount("/static", StaticFiles(directory="static", html=True), name="static")
553
+ app = gr.mount_gradio_app(app, tabs, "/gradio")#, gradio_api_url="http://localhost:7860/")
554
  # テンプレートファイルが格納されているディレクトリを指定
555
  templates = Jinja2Templates(directory="static")
556
 
557
+ #demo4.launch()
558
+ @app.get("/")
559
+ def get_some_page(request: Request):
560
  # テンプレートを使用してHTMLを生成し、返す
561
+ return templates.TemplateResponse("index.html", {"request": request})
562
  # FastAPIのエンドポイントを定義
563
  @app.get("/groq")
564
  def hello_world():
index.html ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <title>My HTML Page</title>
6
+ </head>
7
+ <body>
8
+ <h1>Welcome to my HTML page!</h1>
9
+ </body>
10
+ </html>
sample.csv ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ Name,Age,Score
2
+ Alice,25,90
3
+ Bob,30,85
4
+ Charlie,35,88
5
+ Dave,20,92
6
+ Eve,22,89
static/index.html CHANGED
@@ -1 +1,29 @@
1
- HELLO FROM STATIC
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Iframe Height 100%</title>
7
+ <style>
8
+ /* HTML, body, and parent container must all have 100% height */
9
+ html, body {
10
+ height: 100%;
11
+ margin: 0;
12
+ }
13
+ .iframe-container {
14
+ height: 100%;
15
+ width: 100%;
16
+ }
17
+ iframe {
18
+ height: 100%;
19
+ width: 100%;
20
+ border: none; /* optional, removes the iframe border */
21
+ }
22
+ </style>
23
+ </head>
24
+ <body>
25
+ <div class="iframe-container">
26
+ <iframe src="/gradio"></iframe>
27
+ </div>
28
+ </body>
29
+ </html>