提交 5c2a6b83 编写于 作者: S superyan

Mon Apr 22 11:50:00 CST 2024 inscode

上级 0520122c
import streamlit as st
from streamlit_option_menu import option_menu
import openai
# 设置Streamlit应用程序的标题
st.set_page_config(page_title="app name", layout="wide")
st.title("Code Conversion to Streamlit App")
menu1="菜单1"
menu2="菜单2"
api_key = "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"
openai.api_key = api_key
openai.base_url = "https://integrate.api.nvidia.com/v1"
with st.sidebar:
menu = option_menu("菜单", [menu1, menu2],
icons=['house', "list-task"],
menu_icon="cast", default_index=0)
input_code = st.text_area("Enter the code to convert:", height=200)
def main():
if st.button("Convert to Streamlit App"):
response = openai.Completion.create(
model="meta/llama3-70b",
prompt=f"{input_code}",
temperature=0.5,
top_p=1,
max_tokens=1024,
stream=True
)
if menu == menu1:
st.subheader(f"{menu1}")
output_code = ""
for chunk in response:
output_code += chunk.choices[0].text
if menu == menu2:
st.subheader(f"{menu2}")
if __name__ == '__main__':
main()
st.code(output_code, language="python")
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册