CoolFace
Apppublic

nqtruong/Job_Knowledge_Graph

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
config.py40 linesDownload Raw Back to Knowledge_Graph
1import google.generativeai as genai2from google.generativeai.types import GenerationConfig3from langchain_community.graphs import Neo4jGraph4import instructor5import os6from dotenv import load_dotenv7 8 9 10config = GenerationConfig(11    temperature=0,12    # max_tokens=128,  # Optional: Maximum number of tokens to generate13    # stop_sequences=["<|endoftext|>"]  # Optional: Stop generation at these sequences14)15 16 17def configure_setup():18    load_dotenv()19 20    # Set up Neo4J & Gemini API21    os.environ["NEO4J_URI"] = os.getenv("NEO4J_URI")22    os.environ["NEO4J_USERNAME"] = os.getenv("NEO4J_USERNAME")23    os.environ["NEO4J_PASSWORD"] = os.getenv("NEO4J_PASSWORD")24    os.environ["GEMINI_API_KEY"] = os.getenv("GEMINI_API_KEY")25 26    neo4j_graph = Neo4jGraph()27 28    # Set up Gemini Flash API29    genai.configure(api_key = os.environ["GEMINI_API_KEY"]) # alternative API key configuration30 31    # Create Gemini Client32    client = instructor.from_gemini(33        client=genai.GenerativeModel(34            model_name="models/gemini-1.5-flash-latest",35            generation_config= config# model defaults to "gemini-pro"36        ),37        mode=instructor.Mode.GEMINI_JSON,38    )39 40    return neo4j_graph , client