IvanLee commited on
Commit
4fb2f4e
·
1 Parent(s): 4e3cea8

Test streamlit

Browse files
Files changed (4) hide show
  1. .env +1 -0
  2. __pycache__/app.cpython-310.pyc +0 -0
  3. app.py +17 -15
  4. requirements.txt +4 -8
.env ADDED
@@ -0,0 +1 @@
 
 
1
+ OPENAI_API_KEY=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
__pycache__/app.cpython-310.pyc CHANGED
Binary files a/__pycache__/app.cpython-310.pyc and b/__pycache__/app.cpython-310.pyc differ
 
app.py CHANGED
@@ -1,20 +1,22 @@
1
- from langchain import LLMChain
2
- from langchain.llms import OpenAI
3
- from langchain.prompts import PromptTemplate
4
- import gradio as gr
5
 
6
- # 創建一個簡單的 LangChain
7
- llm = OpenAI(api_key="YOUR_OPENAI_API_KEY")
8
- prompt = PromptTemplate(input_variables=["input"], template="Translate this to French: {input}")
9
- chain = LLMChain(llm=llm, prompt=prompt)
10
 
11
- def langchain_chat(input_text):
12
- response = chain.run(input_text)
13
- return response
14
 
15
- # 使用 Gradio 創建界面
16
- demo = gr.Interface(fn=langchain_chat, inputs="text", outputs="text")
 
17
 
18
- if __name__ == "__main__":
19
- demo.launch()
 
 
20
 
 
 
 
1
+ import streamlit as st
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
 
4
 
5
+ # 設定頁面標題
6
+ st.title('Monthly Random Numbers Line Chart')
 
 
7
 
8
+ # 生成隨機數據
9
+ months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
10
+ data = np.random.randint(0, 100, size=12)
11
 
12
+ # 畫折線圖
13
+ fig, ax = plt.subplots()
14
+ ax.plot(months, data, marker='o')
15
 
16
+ # 設置圖表標題和標籤
17
+ ax.set_title('Random Numbers for Each Month')
18
+ ax.set_xlabel('Month')
19
+ ax.set_ylabel('Random Number')
20
 
21
+ # 顯示圖表
22
+ st.pyplot(fig)
requirements.txt CHANGED
@@ -1,12 +1,8 @@
1
- accelerate
2
- diffusers
3
- invisible_watermark
4
- torch
5
- transformers
6
- xformers
7
- gradio
8
-
9
  openai
10
  langchain
11
  gradio
12
  langchain_community
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  openai
2
  langchain
3
  gradio
4
  langchain_community
5
+
6
+ streamlit
7
+ matplotlib
8
+ numpy