Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,850 Bytes
431aded |
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#!/usr/bin/env python3
from dotenv import load_dotenv
# Load default environment variables (.env)
load_dotenv()
import os
import time
import logging
from collections import deque
from typing import Dict, List
import importlib
import openai
import chromadb
import tiktoken as tiktoken
from chromadb.utils.embedding_functions import OpenAIEmbeddingFunction
from chromadb.api.types import Documents, EmbeddingFunction, Embeddings
import re
from groq import Groq
# default opt out of chromadb telemetry.
from chromadb.config import Settings
from transformers import AutoTokenizer, AutoModel
import torch
import numpy
import psycopg2
import shutil
import gradio as gr
from mysite.libs.utilities import chat_with_interpreter, completion, process_file
from interpreter import interpreter
import mysite.interpreter.interpreter_config # インポートするだけで設定が適用されます
import importlib
import os
import pkgutil
import async_timeout
import asyncio
import sys
from mysite.interpreter.google_chat import send_google_chat_card
def create_vector():
inputs = tokenizer(result, return_tensors="pt", max_length=512, truncation=True)
outputs = model(**inputs)
# [CLS]トークンの出力を取得
embeddings = outputs.last_hidden_state[:,0,:].squeeze().detach().cpu().numpy().tolist()
print(embeddings)
import requests
url = "https://kenken999-php.hf.space/api/v1.php"
payload = f"""model_name={embeddings}&vector_text={result}&table=products&action=insert"""
headers = {
'X-Auth-Token': 'admin',
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': 'runnerSession=muvclb78zpsdjbm7y9c3; pD1lszvk6ratOZhmmgvkp=13767810ebf0782b0b51bf72dedb63b3'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
return True |