-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinferencesprogram.py
More file actions
75 lines (60 loc) · 2.19 KB
/
inferencesprogram.py
File metadata and controls
75 lines (60 loc) · 2.19 KB
1
2
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import openai
import streamlit as st
messages = []
content = ""
chat_response = ""
openai.api_key = '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'
class MultiApp:
def __init__(self):
self.apps = []
def add_app(self, title, func):
self.apps.append({
"title": title,
"function": func
})
def run(self):
st.sidebar.title("추론하는 프로그램")
st.sidebar.subheader("어떤법으로 추론하시겠습니까?")
app = st.sidebar.radio(
'',
self.apps,
format_func=lambda app: app['title'])
app['function']()
def g():
global content
st.title("귀납법 프로그램 실행합니다.")
Ginfer1 = st.text_input("개별적 사실", value = "여러 문장 입력시 ,로 구분해서 쓰시오")
Ginfer2 = st.text_input("소전제")
if st.button("입력"):
content = f"귀납법으로 추론, 개별적 사실은 {Ginfer1}, 소전제는 {Ginfer2}, 결론만 출력"
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": content}
]
)
# 응답 결과 표시
chat_response = completion.choices[0].message.content
st.text(chat_response)
def y():
global content
st.title("연역법 프로그램 실행합니다.")
Yinfer1 = st.text_input("대전체")
Yinfer2 = st.text_input("소전체")
if st.button("입력"):
content = f"연역법으로 추론, 대전제는 {Yinfer1} 소전제는 {Yinfer2}, 결론만 출력"
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": content}
]
)
# 응답 결과 표시
chat_response = completion.choices[0].message.content
st.text(chat_response)
infer = MultiApp()
infer.add_app("귀납법 입력", g)
infer.add_app("연역법 입력", y)
infer.run()