Spaces:
Runtime error
Runtime error
File size: 4,584 Bytes
97d35d2 |
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
import streamlit as st
from source_code import text_completion, chat, GEC, paraphrase, contextual_answer, summarize, improvements
st.title("AI21 Studio Jurassic")
st.image(
image="assets\jurassic.jpg",
caption="Jurassic",
)
st.sidebar.title("Select your preferred tasks")
jurassic_models = [
"j2-light",
"j2-ultra",
"j2-mid",
]
tasks = [
"Generic",
"Specific"
]
# task = st.sidebar.selectbox(
# label="Select your Model",
# options = tasks
# )
disabled = False
# if task == "Generic":
# disabled = False
# task_disable = False
# if task == "Specific":
# task_disable = True
# generic_tasks = [
# "Text Completion",
# # "Chat"
# ]
specific_tasks = [
# "Contextual Answers",
"Paraphrase",
"Summarize",
"Grammetical Error Corrections",
"Text Improvements"
]
# choose_task = generic_tasks
# if task == "Specific":
# choose_task = specific_tasks
choose_task = specific_tasks
choose = st.sidebar.selectbox(
label="Select your tasks",
options = choose_task,
)
# model = st.sidebar.selectbox(
# label="Select your Model",
# options = jurassic_models,
# disabled=disabled
# )
# numResults = st.sidebar.number_input(
# label="Select Number of results",
# min_value=1,
# max_value=5,
# value=1,
# disabled=disabled
# )
# maxTokens = st.sidebar.number_input(
# label="Max Number of Tokens to generate",
# min_value=32,
# max_value=2048,
# value=200,
# step=2,
# disabled=disabled
# )
# temperature = st.sidebar.slider(
# label="Temperature",
# min_value=0.1,
# max_value=1.0,
# value=0.5,
# step=0.1,
# disabled=disabled
# )
# topP = st.sidebar.slider(
# label="Top P",
# min_value=0.1,
# max_value=1.0,
# value=0.6,
# step=0.1,
# disabled=disabled
# )
# topKReturn = st.sidebar.slider(
# label="Top K",
# min_value=1,
# max_value=10,
# value=5,
# step=1,
# disabled=disabled
# )
# context = st.sidebar.text_input(
# label="Context",
# )
# if choose == "Chat":
# question = st.chat_input(key="Question")
# if context is None:
# context = "Everything"
# # template = f"<|system|>\nYou are a intelligent chatbot and expertise in {context}.</s>\n<|user|>\n{question}.\n<|assistant|>"
# template = f"{context}\n{question}"
# if "messages" not in st.session_state:
# st.session_state.messages = []
# for message in st.session_state.messages:
# with st.chat_message(message.get('role')):
# st.write(message.get("content"))
# st.session_state.messages.append(
# {
# "role":"user",
# "content": f"Question: {question}"
# }
# )
# if question:
# result = chat(model, template, numResults, maxTokens, temperature, topKReturn, topP)
# with st.chat_message("user"):
# st.write(f"Context: {context}\n\nQuestion: {question}")
# if question.lower() == "clear":
# del st.session_state.messages
# st.session_state.messages.append(
# {
# "role": "assistant",
# "content": result
# }
# )
# with st.chat_message('User'):
# st.write(f"Context: {context}\n\nQuestion: {question}")
# with st.chat_message('assistant'):
# st.markdown(result)
if 0 > 1:
pass
else:
question = st.text_area(label="Question")
# if context is None:
# context = "Everything"
# template = f"<|system|>\nYou are a intelligent chatbot and expertise in {context}.</s>\n<|user|>\n{question}.\n<|assistant|>"
# if choose == "Text Completion":
# if question:
# result = text_completion(model, template, numResults, maxTokens, temperature, topKReturn, topP)
# st.markdown(result)
# if choose == "Contextual Answers":
# if question:
# result = contextual_answer(context, question)
# st.markdown(result)
if choose == "Paraphrase":
if question:
result = paraphrase(question)
st.markdown(result)
elif choose == "Summarize":
if question:
result = summarize(question)
st.markdown(result)
elif choose == "Grammetical Error Corrections":
if question:
result = GEC(question)
st.markdown(result)
elif choose == "Text Improvements":
if question:
result = improvements(question)
st.markdown(result)
|