Spaces:
Runtime error
Runtime error
activeloop dataset url
Browse files- api/external_services.py +9 -4
- api/main.py +11 -3
api/external_services.py
CHANGED
@@ -71,7 +71,7 @@ class InitiazlizeGithubService:
|
|
71 |
print("Documents uploaded:")
|
72 |
for doc in docs:
|
73 |
print(doc.metadata)
|
74 |
-
|
75 |
return docs
|
76 |
|
77 |
else:
|
@@ -81,6 +81,12 @@ class InitiazlizeGithubService:
|
|
81 |
)
|
82 |
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
class InitiazlizeActiveloopService:
|
85 |
def __init__(self):
|
86 |
self.active_loop_token = get_validate_token(
|
@@ -98,14 +104,13 @@ class InitiazlizeActiveloopService:
|
|
98 |
)
|
99 |
|
100 |
def upload_to_activeloop(self, docs):
|
|
|
101 |
self.index = VectorStoreIndex.from_documents(
|
102 |
docs, storage_context=self.storage_context
|
103 |
)
|
104 |
self.query_engine = self.index.as_query_engine()
|
105 |
|
106 |
def get_user_info(self, user_info):
|
107 |
-
|
108 |
-
yaml_data = yaml.safe_load(file)
|
109 |
-
|
110 |
retrieved_info = yaml_data["info"][user_info]
|
111 |
return retrieved_info
|
|
|
71 |
print("Documents uploaded:")
|
72 |
for doc in docs:
|
73 |
print(doc.metadata)
|
74 |
+
print("return docs\n")
|
75 |
return docs
|
76 |
|
77 |
else:
|
|
|
81 |
)
|
82 |
|
83 |
|
84 |
+
def get_yaml_data():
|
85 |
+
with open("resources.yaml", "r") as file:
|
86 |
+
yaml_data = yaml.safe_load(file)
|
87 |
+
return yaml_data
|
88 |
+
|
89 |
+
|
90 |
class InitiazlizeActiveloopService:
|
91 |
def __init__(self):
|
92 |
self.active_loop_token = get_validate_token(
|
|
|
104 |
)
|
105 |
|
106 |
def upload_to_activeloop(self, docs):
|
107 |
+
print("uploading to activeloop")
|
108 |
self.index = VectorStoreIndex.from_documents(
|
109 |
docs, storage_context=self.storage_context
|
110 |
)
|
111 |
self.query_engine = self.index.as_query_engine()
|
112 |
|
113 |
def get_user_info(self, user_info):
|
114 |
+
yaml_data = get_yaml_data()
|
|
|
|
|
115 |
retrieved_info = yaml_data["info"][user_info]
|
116 |
return retrieved_info
|
api/main.py
CHANGED
@@ -3,7 +3,11 @@ from fastapi import FastAPI
|
|
3 |
from pydantic import BaseModel
|
4 |
from dotenv import load_dotenv
|
5 |
|
6 |
-
from api.external_services import
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# Load environment variables
|
9 |
load_dotenv()
|
@@ -33,8 +37,12 @@ async def scrape_and_upload_to_activeloop(repo_request: GitHubRepoRequest):
|
|
33 |
owner, repo = github_service.parse_github_url(repo_request.githubRepoUrl)
|
34 |
docs = github_service.load_repo_data(owner, repo)
|
35 |
activeloop_service.upload_to_activeloop(docs)
|
36 |
-
|
37 |
-
return {
|
|
|
|
|
|
|
|
|
38 |
|
39 |
|
40 |
@app.post("/retrieve")
|
|
|
3 |
from pydantic import BaseModel
|
4 |
from dotenv import load_dotenv
|
5 |
|
6 |
+
from api.external_services import (
|
7 |
+
InitiazlizeGithubService,
|
8 |
+
InitiazlizeActiveloopService,
|
9 |
+
get_yaml_data,
|
10 |
+
)
|
11 |
|
12 |
# Load environment variables
|
13 |
load_dotenv()
|
|
|
37 |
owner, repo = github_service.parse_github_url(repo_request.githubRepoUrl)
|
38 |
docs = github_service.load_repo_data(owner, repo)
|
39 |
activeloop_service.upload_to_activeloop(docs)
|
40 |
+
user_info = get_yaml_data()
|
41 |
+
return {
|
42 |
+
"status": "success",
|
43 |
+
"message": "Repo processed successfully",
|
44 |
+
"dataset_url": f"https://app.activeloop.ai/{user_info['info']['dataset_path']}",
|
45 |
+
}
|
46 |
|
47 |
|
48 |
@app.post("/retrieve")
|