40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
import streamlit as st
|
|
from SearchManager import perform_search, parse_results
|
|
|
|
|
|
def generate_prompt(user_message: str, file_context=None) -> str:
|
|
# Kontext ist entweder leer oder die angeklickte und geöffnete Datei
|
|
|
|
system_content = """\
|
|
<persona>
|
|
You are an experienced Python coding assistant.
|
|
</persona>
|
|
<style>
|
|
Write python in PEP8 style. Keep explanaitions short.
|
|
</style>
|
|
<constraints>
|
|
Keep each answer under 200 words.
|
|
</constraints>
|
|
"""
|
|
|
|
task = (f"<task> {user_message} </task>")
|
|
|
|
context = ""
|
|
|
|
if "internet" in st.session_state:
|
|
context += (f"<internet_info> {parse_results(perform_search(user_message))} </internet_info>")
|
|
|
|
if "file_content" in st.session_state:
|
|
context += (f" <code> {st.session_state['file_content']} </code>")
|
|
else:
|
|
context = ""
|
|
if "code_error" in st.session_state:
|
|
context += (f" <error> {st.session_state['code_error']} </error>")
|
|
|
|
prompt = system_content + task + context
|
|
|
|
st.session_state["last_prompt"] = (f"{prompt}")
|
|
|
|
return prompt
|
|
|