MEOW commited on
Commit
e73f2ac
·
unverified ·
1 Parent(s): aa7d807

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -17,6 +17,7 @@ import os
17
  import streamlit as st
18
  import pandas as pd #panda dataframe
19
  import numpy as np #numpy arrays
 
20
  from llama_index.core import Settings
21
  from llama_index.core import VectorStoreIndex, StorageContext
22
  from llama_index.core.node_parser import SentenceSplitter
@@ -27,6 +28,27 @@ from llama_index.llms.nvidia import NVIDIA
27
  from document_processors import load_multimodal_data, load_data_from_directory
28
  from utils import set_environment_variables
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  # Set up the page configuration
31
  st.set_page_config(layout="wide")
32
 
 
17
  import streamlit as st
18
  import pandas as pd #panda dataframe
19
  import numpy as np #numpy arrays
20
+ from openai import OpenAI #addition for openai
21
  from llama_index.core import Settings
22
  from llama_index.core import VectorStoreIndex, StorageContext
23
  from llama_index.core.node_parser import SentenceSplitter
 
28
  from document_processors import load_multimodal_data, load_data_from_directory
29
  from utils import set_environment_variables
30
 
31
+ import torch #GPU setup environment start
32
+ from transformers import AutoModel, AutoTokenizer
33
+
34
+ # Check if CUDA is available and set the device
35
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
36
+ print(f"Using device: {device}")
37
+
38
+ # Load model and tokenizer
39
+ model_name = "meta/llama-3.1-8b-instruct"
40
+ model = AutoModel.from_pretrained(model_name).to(device)
41
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
42
+
43
+ # Example function for inference
44
+ def get_response(input_text):
45
+ inputs = tokenizer(input_text, return_tensors="pt").to(device)
46
+ with torch.no_grad():
47
+ outputs = model(**inputs)
48
+ # Process outputs here, this depends on your specific model's output
49
+ return "Your processed output or prediction here" #GPU setup environment end
50
+
51
+
52
  # Set up the page configuration
53
  st.set_page_config(layout="wide")
54