pvanand commited on
Commit
6d4195a
·
1 Parent(s): 2372623

Delete actions/actions_llm.py

Browse files
Files changed (1) hide show
  1. actions/actions_llm.py +0 -47
actions/actions_llm.py DELETED
@@ -1,47 +0,0 @@
1
- # run_search.py
2
- import os
3
- import sys
4
- import openai
5
-
6
- # Add "/actions" to the sys.path
7
- actions_path = os.path.abspath("/actions")
8
- sys.path.insert(0, actions_path)
9
-
10
- # Import search_content.py from /actions folder
11
- from search_content import main_search
12
-
13
-
14
- # Import api key from secrets
15
- secret_value_0 = os.environ.get("openai")
16
-
17
- openai.api_key = secret_value_0
18
- # Provide your OpenAI API key
19
-
20
- def generate_openai_response(query, model_engine="text-davinci-002", max_tokens=124, temperature=0.8):
21
- """Generate a response using the OpenAI API."""
22
- # Run the main function from search_content.py and store the results in a variable
23
- results = main_search(query)
24
-
25
- # Create context from the results
26
- context = "".join([f"#{str(i)}" for i in results])[:2014] # Trim the context to 2014 characters - Modify as necessory
27
- prompt_template = f"Relevant context: {context}\n\n Answer the question in detail: {query}"
28
-
29
- # Generate a response using the OpenAI API
30
- response = openai.Completion.create(
31
- engine=model_engine,
32
- prompt=prompt_template,
33
- max_tokens=max_tokens,
34
- temperature=temperature,
35
- n=1,
36
- stop=None,
37
- )
38
-
39
- return response.choices[0].text.strip()
40
-
41
- def main():
42
- query = "What is omdena local chapters, how a developer can benifit from it"
43
- response = generate_openai_response(query)
44
- print(response)
45
-
46
- if __name__ == "__main__":
47
- main()