Spaces:
Sleeping
Sleeping
File size: 1,487 Bytes
dd390d7 48751e3 dd390d7 48751e3 dd390d7 48751e3 19f35ee dd390d7 4be6e5c dd390d7 19f35ee dd390d7 19f35ee dd390d7 19f35ee dd390d7 19f35ee dd390d7 19f35ee dd390d7 19f35ee dd390d7 |
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 39 40 41 42 43 44 45 46 47 |
# # run_search.py
# import os
# import sys
# import openai
# # Add "/actions" to the sys.path
# actions_path = os.path.abspath("/actions")
# sys.path.insert(0, actions_path)
# # Import search_content.py from /actions folder
# from search_content import main_search
# # Import api key from secrets
# secret_value_0 = os.environ.get("openai")
# openai.api_key = secret_value_0
# # Provide your OpenAI API key
# def generate_openai_response(query, model_engine="text-davinci-002", max_tokens=124, temperature=0.8):
# """Generate a response using the OpenAI API."""
# # Run the main function from search_content.py and store the results in a variable
# results = main_search(query)
# # Create context from the results
# context = "".join([f"#{str(i)}" for i in results])[:2014] # Trim the context to 2014 characters - Modify as necessory
# prompt_template = f"Relevant context: {context}\n\n Answer the question in detail: {query}"
# # Generate a response using the OpenAI API
# response = openai.Completion.create(
# engine=model_engine,
# prompt=prompt_template,
# max_tokens=max_tokens,
# temperature=temperature,
# n=1,
# stop=None,
# )
# return response.choices[0].text.strip()
# def main():
# query = "What is omdena local chapters, how a developer can benifit from it"
# response = generate_openai_response(query)
# print(response)
# if __name__ == "__main__":
# main() |