mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-21 19:21:03 +02:00
Fix LMStudio, cache documents with tg-load-sample-documents
This commit is contained in:
parent
54e475fa3a
commit
ca44894b44
4 changed files with 21 additions and 7 deletions
2
Makefile
2
Makefile
|
|
@ -67,6 +67,8 @@ some-containers:
|
||||||
-t ${CONTAINER_BASE}/trustgraph-flow:${VERSION} .
|
-t ${CONTAINER_BASE}/trustgraph-flow:${VERSION} .
|
||||||
${DOCKER} build -f containers/Containerfile.vertexai \
|
${DOCKER} build -f containers/Containerfile.vertexai \
|
||||||
-t ${CONTAINER_BASE}/trustgraph-vertexai:${VERSION} .
|
-t ${CONTAINER_BASE}/trustgraph-vertexai:${VERSION} .
|
||||||
|
${DOCKER} build -f containers/Containerfile.bedrock \
|
||||||
|
-t ${CONTAINER_BASE}/trustgraph-bedrock:${VERSION} .
|
||||||
|
|
||||||
basic-containers: update-package-versions
|
basic-containers: update-package-versions
|
||||||
${DOCKER} build -f containers/Containerfile.base \
|
${DOCKER} build -f containers/Containerfile.base \
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||||
|
|
||||||
def query(url, flow_id, system, prompt):
|
def query(url, flow_id, system, prompt):
|
||||||
|
|
||||||
api = Api(url).flow().id(flow_id).
|
api = Api(url).flow().id(flow_id)
|
||||||
|
|
||||||
resp = api.text_completion(system=system, prompt=prompt)
|
resp = api.text_completion(system=system, prompt=prompt)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import datetime
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from trustgraph.api import Api
|
from trustgraph.api import Api
|
||||||
from trustgraph.api.types import Uri, Literal, Triple
|
from trustgraph.api.types import hash, Uri, Literal, Triple
|
||||||
|
|
||||||
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
||||||
default_user = 'trustgraph'
|
default_user = 'trustgraph'
|
||||||
|
|
@ -29,6 +29,11 @@ session = requests.session()
|
||||||
|
|
||||||
session.mount('file://', FileAdapter())
|
session.mount('file://', FileAdapter())
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.mkdir("doc-cache")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
documents = [
|
documents = [
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -669,11 +674,19 @@ class Loader:
|
||||||
try:
|
try:
|
||||||
|
|
||||||
print(doc["title"], ":")
|
print(doc["title"], ":")
|
||||||
print(" downloading...")
|
|
||||||
print(" done.")
|
|
||||||
|
|
||||||
resp = session.get(doc["url"])
|
hid = hash(doc["url"])
|
||||||
content = resp.content
|
cache_file = f"doc-cache/{hid}"
|
||||||
|
|
||||||
|
if os.path.isfile(cache_file):
|
||||||
|
print(" (use cache file)")
|
||||||
|
content = open(cache_file, "rb").read()
|
||||||
|
else:
|
||||||
|
print(" downloading...")
|
||||||
|
resp = session.get(doc["url"])
|
||||||
|
content = resp.content
|
||||||
|
open(cache_file, "wb").write(content)
|
||||||
|
print(" done.")
|
||||||
|
|
||||||
print(" adding...")
|
print(" adding...")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ from .... base import LlmService, LlmResult
|
||||||
|
|
||||||
default_ident = "text-completion"
|
default_ident = "text-completion"
|
||||||
|
|
||||||
default_subscriber = module
|
|
||||||
default_model = 'gemma3:9b'
|
default_model = 'gemma3:9b'
|
||||||
default_url = os.getenv("LMSTUDIO_URL", "http://localhost:1234/")
|
default_url = os.getenv("LMSTUDIO_URL", "http://localhost:1234/")
|
||||||
default_temperature = 0.0
|
default_temperature = 0.0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue