Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: adding sample prompt #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions examples/eap_to_quarkus/sampleprompt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import os
from dotenv import find_dotenv, load_dotenv
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
import openai

_ = load_dotenv(find_dotenv())
openai.api_key = os.environ['OPENAI_API_KEY']
chat = ChatOpenAI(temperature=0.0, model="gpt-3.5-turbo")

temp ="""
You have been provided with prior solved examples in {text}. It is time to resolve a similar incident. Find a solution for the issue in {java_code_snippet}.
Make sure it is compatible with Quarkus 3.4.1 as well as Jakarta EE 9 and Java 11.

Make sure the output is displayed in the diff format like github
"""

prompt_template = ChatPromptTemplate.from_template(temp)

modernize_text = """
You are an expert in Java EAP and Quarkus technologies. You are going to assist with modernizing EAP applications to
Quarkus 3.4.1, Jakarta EE 9, and Java 11. There are some sample scenarios provided below,

Example 1:
Incident metdata: Stateless scoped bean

Issue details:

@Stateless
public class OrderService {
// ...
}

Resolution:

@ApplicationScoped
public class OrderService {
// ...
}

Example 2:
Incident metdata: Stateless scoped bean

Issue details:

@Stateless
public class CatalogService {
// ...
}

Resolution:

@ApplicationScoped
public class CatalogService {
// ...
}
"""

modernize_question="""
Incident metadata: Stateless scoped bean

Issue details:
```
@Stateless
public class MemberRegistration {
'....'
'....'
}
```
"""

modernize_messages = prompt_template.format_messages(
text=modernize_text,
java_code_snippet=modernize_question)

modernize_response = chat(modernize_messages)

print(modernize_response.content)
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ nvidia-nccl-cu11==2.14.3
nvidia-nvtx-cu11==11.7.91
openai==0.27.8
openapi-schema-pydantic==1.2.4
openapi-core==0.18.1
openapi-schema-validator==0.6.2
openapi-spec-validator==0.6.0
openllm==0.1.16
openlm==0.0.5
opentelemetry-api==1.17.0
Expand Down