Skip to content

Commit

Permalink
tutorial85
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Jun 14, 2024
1 parent d7105a5 commit 77bfd5c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tutorial85/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import boto3
from langchain_aws import ChatBedrock
client=boto3.client(service_name="bedrock-runtime",region_name="us-east-1")
llm=ChatBedrock(model_id="amazon.titan-text-premier-v1:0",client=client)
response=llm.invoke("write an articvle on AI in Education sector")
print(response.content)
Binary file added tutorial85/tutorial85.pptx
Binary file not shown.
Binary file added tutorial85/~$tutorial85.pptx
Binary file not shown.
Binary file added tutorial86/__pycache__/main.cpython-311.pyc
Binary file not shown.
Empty file added tutorial86/api_llm,.py
Empty file.
37 changes: 37 additions & 0 deletions tutorial86/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from neo4j import GraphDatabase

app = FastAPI()

# Neo4j driver initialization
uri = "bolt://localhost:7687" # Change to your Neo4j URI
user = "neo4j" # Change to your Neo4j username
password = "12345678" # Change to your Neo4j password
driver = GraphDatabase.driver(uri, auth=(user, password))

class Node(BaseModel):
label: str
properties: dict

def create_node_in_neo4j(label: str, properties: dict):
query = f"CREATE (n:{label}) set n= $properties RETURN n"
with driver.session() as session:
x={"properties":properties}
result = session.run(query, x)
return result.single()

@app.post("/nodes/")
async def create_node(node: Node):
try:
result = create_node_in_neo4j(node.label, node.properties)
if result:
return {"message": "Node created successfully", "node": result["n"]}
else:
raise HTTPException(status_code=400, detail="Node creation failed")
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))

if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)

0 comments on commit 77bfd5c

Please sign in to comment.