-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (29 loc) · 882 Bytes
/
main.py
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
from langchain_community.llms import Ollama
from langchain_core.prompts import ChatPromptTemplate
if __name__ == '__main__':
model = Ollama(model="dolphin-mistral")
function_documentation_template = """
Given the following Python function or Class, generate comprehensive documentation including a description, parameters, and return value in reStructredText format.
Function:
{function}
Documentation:
"""
prompt = ChatPromptTemplate.from_messages(
[
(
"system",
function_documentation_template,
)
]
)
chain = prompt | model
# Example usage
example_function = """
def add_numbers(a, b):
\"\"\"Adds two numbers.\"\"\"
return a + b
"""
response = chain.invoke(
{"function": example_function}
)
print(response)