Spaces:
Running
Running
Update components/code_documentation_page.py
Browse files
components/code_documentation_page.py
CHANGED
@@ -1,5 +1,8 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
-
from langchain.
|
|
|
|
|
3 |
|
4 |
def show_doc_page(chat):
|
5 |
st.title("Code Documentation Generator")
|
@@ -9,4 +12,11 @@ def show_doc_page(chat):
|
|
9 |
|
10 |
if st.button("Generate Documentation"):
|
11 |
# Implement the functionality for generating documentation
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# components/code_documentation_page.py
|
2 |
import streamlit as st
|
3 |
+
from langchain.prompts.chat import SystemMessagePromptTemplate, HumanMessagePromptTemplate
|
4 |
+
from langchain.chains import LLMChain
|
5 |
+
from langchain.llms import OpenAI
|
6 |
|
7 |
def show_doc_page(chat):
|
8 |
st.title("Code Documentation Generator")
|
|
|
12 |
|
13 |
if st.button("Generate Documentation"):
|
14 |
# Implement the functionality for generating documentation
|
15 |
+
system_message_prompt = SystemMessagePromptTemplate.from_template("Generate documentation for the provided code snippet.")
|
16 |
+
human_message_prompt = HumanMessagePromptTemplate.from_template("Code snippet:\n{code_snippet}")
|
17 |
+
chat_prompt = SystemMessagePromptTemplate.from_prompt_template(system_message_prompt)
|
18 |
+
chat_prompt.add_message(human_message_prompt)
|
19 |
+
llm = OpenAI(temperature=0.5)
|
20 |
+
chain = LLMChain(llm=llm, prompt=chat_prompt)
|
21 |
+
result = chain.run(code_snippet=code_snippet)
|
22 |
+
st.write(result)
|