code: import json
  import streamlit as st
  import streamlit_ext as ste
  import os
  import time
  import gc
  import pandas as pd
  from dotenv import load_dotenv
  from langchain.chains import LLMChain  # import LangChain libraries
  from langchain.llms import OpenAI  # import OpenAI model
  from langchain.chat_models import ChatOpenAI  # import OpenAI chat model
  from langchain.callbacks import get_openai_callback  # import OpenAI callbacks
  from langchain.prompts import PromptTemplate  # import PromptTemplate
  from langchain.llms import HuggingFacePipeline  # import HuggingFacePipeline
  import torch  # import torch
  # pip install git+https://github.com/huggingface/transformers
  from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList
  
  
  def main():
      load_dotenv(".env")
  
      pipe = None
      open_ai_key = None
      uploaded_file = None
  
      # import css tasks and prompts
      with open('prompts.json') as f:
          promptlib = json.load(f)
  
      hide_default_format = """
         <style>
         #MainMenu {visibility: hidden; }
         footer {visibility: hidden;}
         </style>
         """
      st.markdown(hide_default_format, unsafe_allow_html=True)
  
      # title
      st.title("Prompt Compass")
      st.subheader(
          "A Tool for Navigating LLMs and Prompts for Computational Social Science and Digital Humanities Research")
      # Add Link to your repo
      st.markdown(
          '''
          [![Repo](https://badgen.net/badge/icon/GitHub?icon=github&label)](https://github.com/ErikBorra/PromptCompass)
          [![DOI](https://zenodo.org/badge/649855474.svg)](https://zenodo.org/badge/latestdoi/649855474)
          ''', unsafe_allow_html=True)
      # load available models
      model_with_names = [
          model for model in promptlib['models'] if model['name']]
  
      # create input area for model selection
      input_values = {}
  
      input_values['model'] = st.selectbox('Select a model', model_with_names,
                                           format_func=lambda x: x['name'])
  
      # If there is no previous state, set the default model as the first model
      if not st.session_state.get('previous_model'):
          st.session_state['previous_model'] = model_with_names[0]['name']
  
      st.caption(f"Model info: [{input_values['model']['name']}]({input_values['model']['resource']})" + (
          f". {input_values['model']['comment']}" if 'comment' in input_values['model'] else ""))
  
      # ask for open ai key if no key is set in .env
      if input_values['model']['resource'] in ["https://platform.openai.com/docs/models/gpt-3-5", "https://platform.openai.com/docs/models/gpt-4"]:
          # Load the OpenAI API key from the environment variable
          if os.getenv("OPENAI_API_KEY") is None or os.getenv("OPENAI_API_KEY") == "":
              open_ai_key = st.text_input("Open AI API Key", "")
          else:
              open_ai_key = os.getenv("OPENAI_API_KEY")
  
      # set default values
      do_sample = False
      temperature = 0.001
      top_p = -1
      max_new_tokens = -1
      with st.expander("Advanced settings"):
          if input_values['model']['resource'] not in ["https://platform.openai.com/docs/models/gpt-3-5", "https://platform.openai.com/docs/models/gpt-4"]:
              st.markdown(
                  """
              **Set Maximum Length**: Determines the maximum number of tokens of the **generated** text. A token is approximately four characters word, although this depends on the model.
              A value of -1 means the parameter will not be specified.
              """
              )
              max_new_tokens = st.number_input(
                  'Maximum Length', value=256, min_value=-1, step=1)
              st.markdown(
                  """
              **Set do_sample**: This controls how the model generates text. If do_sample=True, the model will use a probabilistic approach to generate text, where the likelihood of each word being chosen depends on its predicted probability. Use the below parameters to further control its behavior. If do_sample=False, the model will use a deterministic approach and always choose the most likely next word. 
              """
              )
              do_sample = st.radio(
                  'Set do_sample',
                  ('False', 'True')
              )
          st.markdown(
              """
          **Temperature**: Controls the randomness in the model's responses.
          Lower values (closer to 0.0) make the output more deterministic, while higher values (closer to 2.0) make it more diverse.
          A value of -1 means the parameter will not be specified.
          """
          )
          temperature = st.number_input(
              'Set Temperature', min_value=-1.0, max_value=2.0, value=0.001, format="%.3f")
  
          st.markdown(
              """
          **Top P**: Also known as "nucleus sampling", is an alternative to temperature that can also be used to control the randomness of the model's responses.
          It essentially trims the less likely options in the model's distribution of possible responses. Possible values lie between 0.0 and 1.0. 
          A value of -1 means the parameter will not be specified. Only applies if do_sample=True.
          """
          )
          top_p = st.number_input('Set Top-P', min_value=-
                                  1.0, max_value=1.0, value=-1.0)
  
      # Check for correct values
      allgood = True
      # set model kwargs
      model_kwargs = {}
  
      if input_values['model']['resource'] not in ["https://platform.openai.com/docs/models/gpt-3-5", "https://platform.openai.com/docs/models/gpt-4"]:
          # check if max_new_tokens is at least 1 or -1
          if not (max_new_tokens > 0 or max_new_tokens == -1):
              st.error(
                  'Error: Max Tokens must be at least 1. Choose -1 if you want to use the default model value.')
              max_new_tokens = -1
              allgood = False
          if max_new_tokens > 0:
              model_kwargs['max_new_tokens'] = max_new_tokens
  
          if do_sample not in ['True', 'False']:
              st.error(
                  'Error: do_Sample must be True or False')
              do_sample = False
              allgood = False
          do_sample = True if do_sample == 'True' else False
          if do_sample in [True, False]:
              model_kwargs['do_sample'] = do_sample
  
      if not (0 <= temperature <= 2 or temperature == -1):
          st.error(
              "Temperature value must be between 0 and 2. Choose -1 if you want to use the default model value.")
          temperature = -1
          allgood = False
      if 0 <= temperature <= 2:
          model_kwargs['temperature'] = temperature
      if not (0 <= top_p <= 1 or top_p == -1):
          st.error(
              "Top P value must be between 0 and 1. Choose -1 if you want to use the default model value.")
          top_p = -1
          allgood = False
      if 0 <= top_p <= 1:
          model_kwargs['top_p'] = top_p
  
      # create input area for task selection
      tasks_with_names = [task for task in promptlib['tasks'] if task['name']]
      task = st.selectbox('Select a task', tasks_with_names,
                          format_func=lambda x: x['name'] + " - " + x['authors'])
  
      # Create input areas for prompts and user input
      if task:
  
          # concatenate all strings from prompt array
          prompt = '\n'.join(task['prompt'])
  
          # create input area for prompt
          input_values['prompt'] = st.text_area(
              "Inspect, and possibly modify, the prompt by ["+task['authors']+"]("+task['paper']+")", prompt, height=200)
  
          # allow the user to select the input type
          input_type = st.radio("Choose input type:",
                                ('Text input', 'Upload a CSV'), horizontal=True)
  
          if input_type == 'Text input':
              # create input area for user input
              input_values['user'] = st.text_area(
                  "Input to be analyzed with the prompt (one thing per line):",
                  "this user is happy\none user is just a user\nthe other user is a lier")
              # if the user's input is not a list (e.g. a string), then split it by newlines
              if isinstance(input_values['user'], str):
                  input_values['user'] = input_values['user'].split('\n')
              original_data = pd.DataFrame(
                  input_values['user'], columns=['user_input'])
          else:
              # upload CSV
              uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
  
              if uploaded_file is not None:
                  # convert the uploaded file to a dataframe
                  original_data = pd.read_csv(uploaded_file)
  
                  # ask user to select a column
                  column_to_extract = st.selectbox(
                      'Choose a column to apply the prompt on:', original_data.columns)
  
                  # process the selected column from the dataframe
                  input_values['user'] = original_data[column_to_extract].tolist()
  
          data = pd.DataFrame()
  
          # Determine the output file name
          filename = uploaded_file.name if uploaded_file else 'output.csv'
          base_filename, file_extension = os.path.splitext(filename)
          output_filename = f"{base_filename}_promptcompass{file_extension}"
  
      repeat_input = st.number_input(
          'Enter the number of times the prompt/input combination should be repeated:', min_value=1, max_value=10, value=1, step=1)
  
      # Submit button
      submit_button = st.button('Submit')
  
      st.write('---')  # Add a horizontal line
  
      # Process form submission
      if submit_button and allgood:
          if 'user' not in input_values or input_values['user'] is None:
              st.error("No user input provided")
  
          else:
              with st.spinner(text="In progress..."):
  
                  try:
  
                      start_time = time.time()
                      st.write("Start time: " +
                               time.strftime("%H:%M:%S", time.localtime()))
  
                      if input_values['prompt'] and input_values['user']:
  
                          # create prompt template
                          # add location of user input to prompt
                          if task['location_of_input'] == 'before':
                              template = "{user_input}" + \
                                  "\n\n" + input_values['prompt']
                          elif task['location_of_input'] == 'after':
                              template = input_values['prompt'] + \
                                  "\n\n" + "{user_input}"
                          else:
                              template = input_values['prompt']
  
                          # make sure users don't forget the user input variable
                          if "{user_input}" not in template:
                              template = template + "\n\n{user_input}"
  
                          # fill prompt template
                          prompt_template = PromptTemplate(
                              input_variables=["user_input"], template=template)
  
                          # loop over user values in prompt
                          for key, user_input in enumerate(input_values['user']):
  
                              for i in range(repeat_input):
  
                                  num_prompt_tokens = None
                                  num_completion_tokens = None
                                  cost = None
  
                                  user_input = str(user_input).strip()
                                  if user_input == "" or user_input == "nan":
                                      continue
  
                                  # set up and run the model
                                  model_id = input_values['model']['name']
                                  if model_id in ['gpt-3.5-turbo-0125', 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-4-0125-preview', 'gpt-4-1106-preview', 'gpt-4', 'gpt-4-32k', 'gpt-3.5-turbo-instruct', 'babbage-002', 'davinci-002']:
                                      if open_ai_key is None or open_ai_key == "":
                                          st.error(
                                              "Please provide an Open AI API Key")
                                          exit(1)
                                      with get_openai_callback() as cb:
                                          if model_id in ['gpt-3.5-turbo-0125', 'gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-4-0125-preview', 'gpt-4-1106-preview', 'gpt-4', 'gpt-4-32k']:
                                              llm = ChatOpenAI(
                                                  model=model_id, openai_api_key=open_ai_key, **model_kwargs)
                                          else:
                                              llm = OpenAI(
                                                  model=model_id, openai_api_key=open_ai_key, **model_kwargs)
  
                                          llm_chain = LLMChain(
                                              llm=llm, prompt=prompt_template)
  
                                          output = llm_chain.run(user_input)
  
                                          st.success("Input:  " + user_input + "  \n\n " +
                                                     "Output: " + output)
                                          st.text(cb)
                                          num_prompt_tokens = cb.prompt_tokens
                                          num_completion_tokens = cb.completion_tokens
                                          cost = cb.total_cost
  
                                  elif model_id in ['meta-llama/Llama-2-7b-chat-hf', 'meta-llama/Llama-2-13b-chat-hf']:
                                      if pipe == None:
                                          with st.status('Loading model %s' % model_id) as status:
                                              # to use the llama-2 models,
                                              # you first need to get access to the llama-2 models via e.g. https://huggingface.co/meta-llama/Llama-2-7b-chat-hf
                                              # once accepted, get a hugging face auth token https://huggingface.co/settings/tokens
                                              # and then run `huggingface-cli login` on the command line, filling in the generated token
                                              if model_id in ['meta-llama/Llama-2-7b-chat-hf', 'meta-llama/Llama-2-13b-chat-hf']:
                                                  tokenizer = AutoTokenizer.from_pretrained(
                                                      model_id, use_auth_token=True)
                                              else:
                                                  tokenizer = AutoTokenizer.from_pretrained(
                                                      model_id)
  
                                              if model_id == "meta-llama/Llama-2-13b-chat-hf":
                                                  pipe = pipeline(
                                                      "text-generation",
                                                      model=model_id,
                                                      tokenizer=tokenizer,
                                                      # torch_dtype="auto",
                                                      trust_remote_code=True,
                                                      device_map="auto",
                                                      num_return_sequences=1,
                                                      eos_token_id=tokenizer.eos_token_id,
                                                      **model_kwargs
                                                  )
                                              else:
                                                  pipe = pipeline(
                                                      "text-generation",
                                                      model=model_id,
                                                      tokenizer=tokenizer,
                                                      torch_dtype="auto",
                                                      trust_remote_code=True,
                                                      device_map="auto",
                                                      num_return_sequences=1,
                                                      eos_token_id=tokenizer.eos_token_id,
                                                      **model_kwargs
                                                  )
  
                                              local_llm = HuggingFacePipeline(
                                                  pipeline=pipe)
  
                                          status.update(
                                              label='Model %s loaded' % model_id, state="complete")
  
                                      llm_chain = LLMChain(
                                          llm=local_llm, prompt=prompt_template)
  
                                      output = llm_chain.run(user_input)
  
                                      st.success("Input:  " + user_input + "  \n\n " +
                                                 "Output: " + output)
                                  elif model_id in ['google/flan-t5-large', 'google/flan-t5-xl', 'tiiuae/falcon-7b-instruct', 'tiiuae/falcon-40b-instruct', 'databricks/dolly-v2-3b', 'databricks/dolly-v2-7b']:
                                      if pipe is None:
                                          with st.status('Loading model %s' % model_id) as status:
                                              tokenizer = AutoTokenizer.from_pretrained(
                                                  model_id)
  
                                              if model_id in ['google/flan-t5-large', 'google/flan-t5-xl']:
                                                  model = AutoModelForSeq2SeqLM.from_pretrained(
                                                      model_id, load_in_8bit=False, device_map='auto')
                                                  pipe = pipeline(
                                                      "text2text-generation",
                                                      model=model_id,
                                                      tokenizer=tokenizer,
                                                      torch_dtype="auto",
                                                      trust_remote_code=True,
                                                      device_map="auto",
                                                      num_return_sequences=1,
                                                      eos_token_id=tokenizer.eos_token_id,
                                                      **model_kwargs
                                                  )
                                              # elif model_id in ['tiiuae/falcon-7b-instruct', 'tiiuae/falcon-40b-instruct']:
                                              else:
                                                  pipe = pipeline(
                                                      "text-generation",
                                                      model=model_id,
                                                      tokenizer=tokenizer,
                                                      torch_dtype="auto",
                                                      trust_remote_code=True,
                                                      device_map="auto",
                                                      num_return_sequences=1,
                                                      eos_token_id=tokenizer.eos_token_id,
                                                      **model_kwargs
                                                  )
  
                                              local_llm = HuggingFacePipeline(
                                                  pipeline=pipe)
                                              status.update(
                                                  label='Model %s loaded' % model_id, state="complete")
  
                                      llm_chain = LLMChain(
                                          llm=local_llm, prompt=prompt_template)
  
                                      output = llm_chain.run(user_input)
  
                                      st.success("Input:  " + user_input + "  \n\n " +
                                                 "Output: " + output)
                                  elif model_id == "mosaicml/mpt-7b-instruct":
                                      if pipe is None:
                                          with st.status('Loading model %s' % model_id) as status:
  
                                              model = AutoModelForCausalLM.from_pretrained(
                                                  model_id,
                                                  trust_remote_code=True,
                                                  torch_dtype=torch.bfloat16,
                                                  max_seq_len=2048,
                                                  device_map="auto"
                                              )
  
                                              # MPT-7B model was trained using the EleutherAI/gpt-neox-20b tokenizer
                                              tokenizer = AutoTokenizer.from_pretrained(
                                                  "EleutherAI/gpt-neox-20b")
  
                                              # mtp-7b is trained to add "<|endoftext|>" at the end of generations
                                              stop_token_ids = tokenizer.convert_tokens_to_ids(
                                                  ["<|endoftext|>"])
  
                                              # define custom stopping criteria object
                                              class StopOnTokens(StoppingCriteria):
                                                  def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
                                                      for stop_id in stop_token_ids:
                                                          if input_ids[0][-1] == stop_id:
                                                              return True
                                                      return False
                                              stopping_criteria = StoppingCriteriaList(
                                                  [StopOnTokens()])
  
                                              pipe = pipeline(
                                                  task='text-generation',
                                                  model=model,
                                                  tokenizer=tokenizer,
                                                  torch_dtype="auto",
                                                  device_map="auto",
                                                  num_return_sequences=1,
                                                  eos_token_id=tokenizer.eos_token_id,
                                                  **model_kwargs,
                                                  return_full_text=True,  # langchain expects the full text
                                                  stopping_criteria=stopping_criteria,  # without this model will ramble
                                                  repetition_penalty=1.1  # without this output begins repeating
                                              )
  
                                              local_llm = HuggingFacePipeline(
                                                  pipeline=pipe)
  
                                          status.update(
                                              label='Model %s loaded' % model_id, state="complete")
  
                                      llm_chain = LLMChain(
                                          llm=local_llm, prompt=prompt_template)
  
                                      output = llm_chain.run(user_input)
  
                                      st.success("Input:  " + user_input + "  \n\n " +
                                                 "Output: " + output)
                                  elif model_id == "allenai/OLMo-7B" or model_id == "ehartford/dolphin-2.1-mistral-7b" or model_id == "lvkaokao/mistral-7b-finetuned-orca-dpo-v2" or model_id == "lmsys/vicuna-13b-v1.5" or model_id == "microsoft/Orca-2-13b":
                                      if pipe is None:
                                          with st.status('Loading model %s' % model_id) as status:
  
                                              model = AutoModelForCausalLM.from_pretrained(
                                                  model_id,
                                                  trust_remote_code=True,
                                                  torch_dtype=torch.bfloat16,
                                                  device_map="auto"
                                              )
  
                                              if model_id == "ehartford/dolphin-2.1-mistral-7b":
                                                  tokenizer = AutoTokenizer.from_pretrained(
                                                      model_id, use_fast=False)
                                              else:
                                                  tokenizer = AutoTokenizer.from_pretrained(
                                                      model_id)
  
                                              pipe = pipeline(
                                                  task='text-generation',
                                                  model=model,
                                                  tokenizer=tokenizer,
                                                  torch_dtype="auto",
                                                  device_map="auto",
                                                  num_return_sequences=1,
                                                  eos_token_id=tokenizer.eos_token_id,
                                                  **model_kwargs,
                                                  return_full_text=True,  # langchain expects the full text
                                              )
  
                                              local_llm = HuggingFacePipeline(
                                                  pipeline=pipe)
  
                                          status.update(
                                              label='Model %s loaded' % model_id, state="complete")
  
                                      llm_chain = LLMChain(
                                          llm=local_llm, prompt=prompt_template)
  
                                      output = llm_chain.run(user_input)
  
                                      st.success("Input:  " + user_input + "  \n\n " +
                                                 "Output: " + output)
                                  else:
                                      st.error("Model %s not found" % model_id)
                                      exit(1)
  
                                  if not num_prompt_tokens or not num_completion_tokens:
                                      num_prompt_tokens = len(tokenizer.tokenize(
                                          prompt_template.format(user_input=user_input)))
                                      num_completion_tokens = len(tokenizer.tokenize(
                                          output))
  
                                  # Prepare data as dictionary
                                  original_row = original_data.loc[key].copy()
  
                                  new_row = {
                                      'user_input': user_input,
                                      'output': output,
                                      'llm': model_id,
                                      'prompt name': task['name'],
                                      'prompt authors': task['authors'],
                                      'prompt': template,
                                      'timestamp': time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
                                      '# prompt tokens': str(int(num_prompt_tokens)),
                                      '# completion tokens': str(int(num_completion_tokens)),
                                      'max_new_tokens': int(model_kwargs['max_new_tokens']) if "max_new_tokens" in model_kwargs else None,
                                      'do_sample': int(model_kwargs['do_sample']) if "do_sample" in model_kwargs else None,
                                      'temperature': model_kwargs['temperature'] if "temperature" in model_kwargs else None,
                                      'top_p': model_kwargs['top_p'] if "top_p" in model_kwargs else None,
                                      'cost': cost if cost is not None else None
                                  }
  
                                  # Update the original row with the new data
                                  for key2, value in new_row.items():
                                      original_row[key2] = value
  
                                  # Append the updated row to the DataFrame
                                  updated_row_df = pd.DataFrame([original_row])
                                  data = pd.concat(
                                      [data, updated_row_df], ignore_index=True)
  
                          st.subheader("Results")
                          st.dataframe(data, column_config={},
                                       hide_index=True)
  
                          # make output available as csv
                          csv = data.to_csv(index=False).encode('utf-8')
                          ste.download_button(
                              "Download CSV",
                              csv,
                              output_filename,
                              "text/csv",
                          )
  
                      end_time = time.time()
                      elapsed_time = end_time - start_time
                      st.write("End time: " +
                               time.strftime("%H:%M:%S", time.localtime()))
                      st.write("Elapsed time: " +
                               str(round(elapsed_time, 2)) + " seconds")
  
                  except Exception as e:
                      st.error(e)
  
                  finally:
                      # free up variables
                      if 'data' in locals() and data is not None:
                          del data
                      if 'pipe' in locals() and pipe is not None:
                          del pipe
                      if 'llm_chain' in locals() and llm_chain is not None:
                          del llm_chain
                      if 'llm' in locals() and llm is not None:
                          del llm
                      if 'local_llm' in locals() and local_llm is not None:
                          del local_llm
                      if 'model' in locals() and model is not None:
                          del model
                      if 'tokenizer' in locals() and tokenizer is not None:
                          del tokenizer
                      gc.collect()  # garbage collection
                      # empty cuda cache
                      torch.cuda.empty_cache()
  
  
  if __name__ == "__main__":
      main()
  
apis: langchain.chains.LLMChain langchain.chat_models.ChatOpenAI langchain.llms.OpenAI langchain.prompts.PromptTemplate langchain.callbacks.get_openai_callback langchain.llms.HuggingFacePipeline
extract_api: [((813, 832), 'dotenv.load_dotenv', 'load_dotenv', (['""".env"""'], {}), "('.env')\n", (824, 832), False, 'from dotenv import load_dotenv\n'), ((1156, 1212), 'streamlit.markdown', 'st.markdown', (['hide_default_format'], {'unsafe_allow_html': '(True)'}), '(hide_default_format, unsafe_allow_html=True)\n', (1167, 1212), True, 'import streamlit as st\n'), ((1230, 1256), 'streamlit.title', 'st.title', (['"""Prompt Compass"""'], {}), "('Prompt Compass')\n", (1238, 1256), True, 'import streamlit as st\n'), ((1261, 1390), 'streamlit.subheader', 'st.subheader', (['"""A Tool for Navigating LLMs and Prompts for Computational Social Science and Digital Humanities Research"""'], {}), "(\n    'A Tool for Navigating LLMs and Prompts for Computational Social Science and Digital Humanities Research'\n    )\n", (1273, 1390), True, 'import streamlit as st\n'), ((1422, 1705), 'streamlit.markdown', 'st.markdown', (['"""\n        [![Repo](https://badgen.net/badge/icon/GitHub?icon=github&label)](https://github.com/ErikBorra/PromptCompass)\n        [![DOI](https://zenodo.org/badge/649855474.svg)](https://zenodo.org/badge/latestdoi/649855474)\n        """'], {'unsafe_allow_html': '(True)'}), '(\n    """\n        [![Repo](https://badgen.net/badge/icon/GitHub?icon=github&label)](https://github.com/ErikBorra/PromptCompass)\n        [![DOI](https://zenodo.org/badge/649855474.svg)](https://zenodo.org/badge/latestdoi/649855474)\n        """\n    , unsafe_allow_html=True)\n', (1433, 1705), True, 'import streamlit as st\n'), ((1919, 2005), 'streamlit.selectbox', 'st.selectbox', (['"""Select a model"""', 'model_with_names'], {'format_func': "(lambda x: x['name'])"}), "('Select a model', model_with_names, format_func=lambda x: x[\n    'name'])\n", (1931, 2005), True, 'import streamlit as st\n'), ((2250, 2451), 'streamlit.caption', 'st.caption', (['(f"Model info: [{input_values[\'model\'][\'name\']}]({input_values[\'model\'][\'resource\']})"\n     + (f". {input_values[\'model\'][\'comment\']}" if \'comment\' in\n    input_values[\'model\'] else \'\'))'], {}), '(\n    f"Model info: [{input_values[\'model\'][\'name\']}]({input_values[\'model\'][\'resource\']})"\n     + (f". {input_values[\'model\'][\'comment\']}" if \'comment\' in\n    input_values[\'model\'] else \'\'))\n', (2260, 2451), True, 'import streamlit as st\n'), ((7021, 7129), 'streamlit.selectbox', 'st.selectbox', (['"""Select a task"""', 'tasks_with_names'], {'format_func': "(lambda x: x['name'] + ' - ' + x['authors'])"}), "('Select a task', tasks_with_names, format_func=lambda x: x[\n    'name'] + ' - ' + x['authors'])\n", (7033, 7129), True, 'import streamlit as st\n'), ((9240, 9387), 'streamlit.number_input', 'st.number_input', (['"""Enter the number of times the prompt/input combination should be repeated:"""'], {'min_value': '(1)', 'max_value': '(10)', 'value': '(1)', 'step': '(1)'}), "(\n    'Enter the number of times the prompt/input combination should be repeated:'\n    , min_value=1, max_value=10, value=1, step=1)\n", (9255, 9387), True, 'import streamlit as st\n'), ((9428, 9447), 'streamlit.button', 'st.button', (['"""Submit"""'], {}), "('Submit')\n", (9437, 9447), True, 'import streamlit as st\n'), ((9453, 9468), 'streamlit.write', 'st.write', (['"""---"""'], {}), "('---')\n", (9461, 9468), True, 'import streamlit as st\n'), ((990, 1002), 'json.load', 'json.load', (['f'], {}), '(f)\n', (999, 1002), False, 'import json\n'), ((2132, 2170), 'streamlit.session_state.get', 'st.session_state.get', (['"""previous_model"""'], {}), "('previous_model')\n", (2152, 2170), True, 'import streamlit as st\n'), ((3045, 3077), 'streamlit.expander', 'st.expander', (['"""Advanced settings"""'], {}), "('Advanced settings')\n", (3056, 3077), True, 'import streamlit as st\n'), ((4283, 4592), 'streamlit.markdown', 'st.markdown', (['"""\n        **Temperature**: Controls the randomness in the model\'s responses.\n        Lower values (closer to 0.0) make the output more deterministic, while higher values (closer to 2.0) make it more diverse.\n        A value of -1 means the parameter will not be specified.\n        """'], {}), '(\n    """\n        **Temperature**: Controls the randomness in the model\'s responses.\n        Lower values (closer to 0.0) make the output more deterministic, while higher values (closer to 2.0) make it more diverse.\n        A value of -1 means the parameter will not be specified.\n        """\n    )\n', (4294, 4592), True, 'import streamlit as st\n'), ((4627, 4725), 'streamlit.number_input', 'st.number_input', (['"""Set Temperature"""'], {'min_value': '(-1.0)', 'max_value': '(2.0)', 'value': '(0.001)', 'format': '"""%.3f"""'}), "('Set Temperature', min_value=-1.0, max_value=2.0, value=\n    0.001, format='%.3f')\n", (4642, 4725), True, 'import streamlit as st\n'), ((4743, 5184), 'streamlit.markdown', 'st.markdown', (['"""\n        **Top P**: Also known as "nucleus sampling", is an alternative to temperature that can also be used to control the randomness of the model\'s responses.\n        It essentially trims the less likely options in the model\'s distribution of possible responses. Possible values lie between 0.0 and 1.0. \n        A value of -1 means the parameter will not be specified. Only applies if do_sample=True.\n        """'], {}), '(\n    """\n        **Top P**: Also known as "nucleus sampling", is an alternative to temperature that can also be used to control the randomness of the model\'s responses.\n        It essentially trims the less likely options in the model\'s distribution of possible responses. Possible values lie between 0.0 and 1.0. \n        A value of -1 means the parameter will not be specified. Only applies if do_sample=True.\n        """\n    )\n', (4754, 5184), True, 'import streamlit as st\n'), ((5213, 5284), 'streamlit.number_input', 'st.number_input', (['"""Set Top-P"""'], {'min_value': '(-1.0)', 'max_value': '(1.0)', 'value': '(-1.0)'}), "('Set Top-P', min_value=-1.0, max_value=1.0, value=-1.0)\n", (5228, 5284), True, 'import streamlit as st\n'), ((6364, 6482), 'streamlit.error', 'st.error', (['"""Temperature value must be between 0 and 2. Choose -1 if you want to use the default model value."""'], {}), "(\n    'Temperature value must be between 0 and 2. Choose -1 if you want to use the default model value.'\n    )\n", (6372, 6482), True, 'import streamlit as st\n'), ((6668, 6780), 'streamlit.error', 'st.error', (['"""Top P value must be between 0 and 1. Choose -1 if you want to use the default model value."""'], {}), "(\n    'Top P value must be between 0 and 1. Choose -1 if you want to use the default model value.'\n    )\n", (6676, 6780), True, 'import streamlit as st\n'), ((7384, 7517), 'streamlit.text_area', 'st.text_area', (["('Inspect, and possibly modify, the prompt by [' + task['authors'] + '](' +\n    task['paper'] + ')')", 'prompt'], {'height': '(200)'}), "('Inspect, and possibly modify, the prompt by [' + task[\n    'authors'] + '](' + task['paper'] + ')', prompt, height=200)\n", (7396, 7517), True, 'import streamlit as st\n'), ((7590, 7669), 'streamlit.radio', 'st.radio', (['"""Choose input type:"""', "('Text input', 'Upload a CSV')"], {'horizontal': '(True)'}), "('Choose input type:', ('Text input', 'Upload a CSV'), horizontal=True)\n", (7598, 7669), True, 'import streamlit as st\n'), ((8948, 8962), 'pandas.DataFrame', 'pd.DataFrame', ([], {}), '()\n', (8960, 8962), True, 'import pandas as pd\n'), ((9118, 9144), 'os.path.splitext', 'os.path.splitext', (['filename'], {}), '(filename)\n', (9134, 9144), False, 'import os\n'), ((2820, 2856), 'streamlit.text_input', 'st.text_input', (['"""Open AI API Key"""', '""""""'], {}), "('Open AI API Key', '')\n", (2833, 2856), True, 'import streamlit as st\n'), ((2897, 2924), 'os.getenv', 'os.getenv', (['"""OPENAI_API_KEY"""'], {}), "('OPENAI_API_KEY')\n", (2906, 2924), False, 'import os\n'), ((3245, 3542), 'streamlit.markdown', 'st.markdown', (['"""\n            **Set Maximum Length**: Determines the maximum number of tokens of the **generated** text. A token is approximately four characters word, although this depends on the model.\n            A value of -1 means the parameter will not be specified.\n            """'], {}), '(\n    """\n            **Set Maximum Length**: Determines the maximum number of tokens of the **generated** text. A token is approximately four characters word, although this depends on the model.\n            A value of -1 means the parameter will not be specified.\n            """\n    )\n', (3256, 3542), True, 'import streamlit as st\n'), ((3592, 3658), 'streamlit.number_input', 'st.number_input', (['"""Maximum Length"""'], {'value': '(256)', 'min_value': '(-1)', 'step': '(1)'}), "('Maximum Length', value=256, min_value=-1, step=1)\n", (3607, 3658), True, 'import streamlit as st\n'), ((3688, 4139), 'streamlit.markdown', 'st.markdown', (['"""\n            **Set do_sample**: This controls how the model generates text. If do_sample=True, the model will use a probabilistic approach to generate text, where the likelihood of each word being chosen depends on its predicted probability. Use the below parameters to further control its behavior. If do_sample=False, the model will use a deterministic approach and always choose the most likely next word. \n            """'], {}), '(\n    """\n            **Set do_sample**: This controls how the model generates text. If do_sample=True, the model will use a probabilistic approach to generate text, where the likelihood of each word being chosen depends on its predicted probability. Use the below parameters to further control its behavior. If do_sample=False, the model will use a deterministic approach and always choose the most likely next word. \n            """\n    )\n', (3699, 4139), True, 'import streamlit as st\n'), ((4184, 4228), 'streamlit.radio', 'st.radio', (['"""Set do_sample"""', "('False', 'True')"], {}), "('Set do_sample', ('False', 'True'))\n", (4192, 4228), True, 'import streamlit as st\n'), ((5692, 5805), 'streamlit.error', 'st.error', (['"""Error: Max Tokens must be at least 1. Choose -1 if you want to use the default model value."""'], {}), "(\n    'Error: Max Tokens must be at least 1. Choose -1 if you want to use the default model value.'\n    )\n", (5700, 5805), True, 'import streamlit as st\n'), ((6024, 6074), 'streamlit.error', 'st.error', (['"""Error: do_Sample must be True or False"""'], {}), "('Error: do_Sample must be True or False')\n", (6032, 6074), True, 'import streamlit as st\n'), ((7822, 7975), 'streamlit.text_area', 'st.text_area', (['"""Input to be analyzed with the prompt (one thing per line):"""', '"""this user is happy\none user is just a user\nthe other user is a lier"""'], {}), '(\'Input to be analyzed with the prompt (one thing per line):\',\n    """this user is happy\none user is just a user\nthe other user is a lier""")\n', (7834, 7975), True, 'import streamlit as st\n'), ((8248, 8306), 'pandas.DataFrame', 'pd.DataFrame', (["input_values['user']"], {'columns': "['user_input']"}), "(input_values['user'], columns=['user_input'])\n", (8260, 8306), True, 'import pandas as pd\n'), ((8391, 8440), 'streamlit.file_uploader', 'st.file_uploader', (['"""Choose a CSV file"""'], {'type': '"""csv"""'}), "('Choose a CSV file', type='csv')\n", (8407, 8440), True, 'import streamlit as st\n'), ((9642, 9676), 'streamlit.error', 'st.error', (['"""No user input provided"""'], {}), "('No user input provided')\n", (9650, 9676), True, 'import streamlit as st\n'), ((2720, 2747), 'os.getenv', 'os.getenv', (['"""OPENAI_API_KEY"""'], {}), "('OPENAI_API_KEY')\n", (2729, 2747), False, 'import os\n'), ((2759, 2786), 'os.getenv', 'os.getenv', (['"""OPENAI_API_KEY"""'], {}), "('OPENAI_API_KEY')\n", (2768, 2786), False, 'import os\n'), ((8575, 8601), 'pandas.read_csv', 'pd.read_csv', (['uploaded_file'], {}), '(uploaded_file)\n', (8586, 8601), True, 'import pandas as pd\n'), ((8685, 8763), 'streamlit.selectbox', 'st.selectbox', (['"""Choose a column to apply the prompt on:"""', 'original_data.columns'], {}), "('Choose a column to apply the prompt on:', original_data.columns)\n", (8697, 8763), True, 'import streamlit as st\n'), ((9709, 9742), 'streamlit.spinner', 'st.spinner', ([], {'text': '"""In progress..."""'}), "(text='In progress...')\n", (9719, 9742), True, 'import streamlit as st\n'), ((9800, 9811), 'time.time', 'time.time', ([], {}), '()\n', (9809, 9811), False, 'import time\n'), ((29699, 29710), 'time.time', 'time.time', ([], {}), '()\n', (29708, 29710), False, 'import time\n'), ((30887, 30899), 'gc.collect', 'gc.collect', ([], {}), '()\n', (30897, 30899), False, 'import gc\n'), ((30981, 31005), 'torch.cuda.empty_cache', 'torch.cuda.empty_cache', ([], {}), '()\n', (31003, 31005), False, 'import torch\n'), ((10885, 10950), 'langchain.prompts.PromptTemplate', 'PromptTemplate', ([], {'input_variables': "['user_input']", 'template': 'template'}), "(input_variables=['user_input'], template=template)\n", (10899, 10950), False, 'from langchain.prompts import PromptTemplate\n'), ((29168, 29191), 'streamlit.subheader', 'st.subheader', (['"""Results"""'], {}), "('Results')\n", (29180, 29191), True, 'import streamlit as st\n'), ((29216, 29269), 'streamlit.dataframe', 'st.dataframe', (['data'], {'column_config': '{}', 'hide_index': '(True)'}), '(data, column_config={}, hide_index=True)\n', (29228, 29269), True, 'import streamlit as st\n'), ((29458, 29527), 'streamlit_ext.download_button', 'ste.download_button', (['"""Download CSV"""', 'csv', 'output_filename', '"""text/csv"""'], {}), "('Download CSV', csv, output_filename, 'text/csv')\n", (29477, 29527), True, 'import streamlit_ext as ste\n'), ((30065, 30076), 'streamlit.error', 'st.error', (['e'], {}), '(e)\n', (30073, 30076), True, 'import streamlit as st\n'), ((9913, 9929), 'time.localtime', 'time.localtime', ([], {}), '()\n', (9927, 9929), False, 'import time\n'), ((28985, 29013), 'pandas.DataFrame', 'pd.DataFrame', (['[original_row]'], {}), '([original_row])\n', (28997, 29013), True, 'import pandas as pd\n'), ((29053, 29105), 'pandas.concat', 'pd.concat', (['[data, updated_row_df]'], {'ignore_index': '(True)'}), '([data, updated_row_df], ignore_index=True)\n', (29062, 29105), True, 'import pandas as pd\n'), ((29867, 29883), 'time.localtime', 'time.localtime', ([], {}), '()\n', (29881, 29883), False, 'import time\n'), ((12017, 12062), 'streamlit.error', 'st.error', (['"""Please provide an Open AI API Key"""'], {}), "('Please provide an Open AI API Key')\n", (12025, 12062), True, 'import streamlit as st\n'), ((12197, 12218), 'langchain.callbacks.get_openai_callback', 'get_openai_callback', ([], {}), '()\n', (12216, 12218), False, 'from langchain.callbacks import get_openai_callback\n'), ((12844, 12885), 'langchain.chains.LLMChain', 'LLMChain', ([], {'llm': 'llm', 'prompt': 'prompt_template'}), '(llm=llm, prompt=prompt_template)\n', (12852, 12885), False, 'from langchain.chains import LLMChain\n'), ((13048, 13117), 'streamlit.success', 'st.success', (["('Input:  ' + user_input + '  \\n\\n ' + 'Output: ' + output)"], {}), "('Input:  ' + user_input + '  \\n\\n ' + 'Output: ' + output)\n", (13058, 13117), True, 'import streamlit as st\n'), ((13209, 13220), 'streamlit.text', 'st.text', (['cb'], {}), '(cb)\n', (13216, 13220), True, 'import streamlit as st\n'), ((16761, 16808), 'langchain.chains.LLMChain', 'LLMChain', ([], {'llm': 'local_llm', 'prompt': 'prompt_template'}), '(llm=local_llm, prompt=prompt_template)\n', (16769, 16808), False, 'from langchain.chains import LLMChain\n'), ((16959, 17028), 'streamlit.success', 'st.success', (["('Input:  ' + user_input + '  \\n\\n ' + 'Output: ' + output)"], {}), "('Input:  ' + user_input + '  \\n\\n ' + 'Output: ' + output)\n", (16969, 17028), True, 'import streamlit as st\n'), ((27858, 27874), 'time.localtime', 'time.localtime', ([], {}), '()\n', (27872, 27874), False, 'import time\n'), ((12459, 12529), 'langchain.chat_models.ChatOpenAI', 'ChatOpenAI', ([], {'model': 'model_id', 'openai_api_key': 'open_ai_key'}), '(model=model_id, openai_api_key=open_ai_key, **model_kwargs)\n', (12469, 12529), False, 'from langchain.chat_models import ChatOpenAI\n'), ((12675, 12741), 'langchain.llms.OpenAI', 'OpenAI', ([], {'model': 'model_id', 'openai_api_key': 'open_ai_key'}), '(model=model_id, openai_api_key=open_ai_key, **model_kwargs)\n', (12681, 12741), False, 'from langchain.llms import OpenAI\n'), ((19967, 20014), 'langchain.chains.LLMChain', 'LLMChain', ([], {'llm': 'local_llm', 'prompt': 'prompt_template'}), '(llm=local_llm, prompt=prompt_template)\n', (19975, 20014), False, 'from langchain.chains import LLMChain\n'), ((20165, 20234), 'streamlit.success', 'st.success', (["('Input:  ' + user_input + '  \\n\\n ' + 'Output: ' + output)"], {}), "('Input:  ' + user_input + '  \\n\\n ' + 'Output: ' + output)\n", (20175, 20234), True, 'import streamlit as st\n'), ((13661, 13701), 'streamlit.status', 'st.status', (["('Loading model %s' % model_id)"], {}), "('Loading model %s' % model_id)\n", (13670, 13701), True, 'import streamlit as st\n'), ((16474, 16508), 'langchain.llms.HuggingFacePipeline', 'HuggingFacePipeline', ([], {'pipeline': 'pipe'}), '(pipeline=pipe)\n', (16493, 16508), False, 'from langchain.llms import HuggingFacePipeline\n'), ((23653, 23700), 'langchain.chains.LLMChain', 'LLMChain', ([], {'llm': 'local_llm', 'prompt': 'prompt_template'}), '(llm=local_llm, prompt=prompt_template)\n', (23661, 23700), False, 'from langchain.chains import LLMChain\n'), ((23851, 23920), 'streamlit.success', 'st.success', (["('Input:  ' + user_input + '  \\n\\n ' + 'Output: ' + output)"], {}), "('Input:  ' + user_input + '  \\n\\n ' + 'Output: ' + output)\n", (23861, 23920), True, 'import streamlit as st\n'), ((14398, 14458), 'transformers.AutoTokenizer.from_pretrained', 'AutoTokenizer.from_pretrained', (['model_id'], {'use_auth_token': '(True)'}), '(model_id, use_auth_token=True)\n', (14427, 14458), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((14622, 14661), 'transformers.AutoTokenizer.from_pretrained', 'AutoTokenizer.from_pretrained', (['model_id'], {}), '(model_id)\n', (14651, 14661), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((14864, 15056), 'transformers.pipeline', 'pipeline', (['"""text-generation"""'], {'model': 'model_id', 'tokenizer': 'tokenizer', 'trust_remote_code': '(True)', 'device_map': '"""auto"""', 'num_return_sequences': '(1)', 'eos_token_id': 'tokenizer.eos_token_id'}), "('text-generation', model=model_id, tokenizer=tokenizer,\n    trust_remote_code=True, device_map='auto', num_return_sequences=1,\n    eos_token_id=tokenizer.eos_token_id, **model_kwargs)\n", (14872, 15056), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((15694, 15911), 'transformers.pipeline', 'pipeline', (['"""text-generation"""'], {'model': 'model_id', 'tokenizer': 'tokenizer', 'torch_dtype': '"""auto"""', 'trust_remote_code': '(True)', 'device_map': '"""auto"""', 'num_return_sequences': '(1)', 'eos_token_id': 'tokenizer.eos_token_id'}), "('text-generation', model=model_id, tokenizer=tokenizer,\n    torch_dtype='auto', trust_remote_code=True, device_map='auto',\n    num_return_sequences=1, eos_token_id=tokenizer.eos_token_id, **model_kwargs\n    )\n", (15702, 15911), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((17381, 17421), 'streamlit.status', 'st.status', (["('Loading model %s' % model_id)"], {}), "('Loading model %s' % model_id)\n", (17390, 17421), True, 'import streamlit as st\n'), ((17489, 17528), 'transformers.AutoTokenizer.from_pretrained', 'AutoTokenizer.from_pretrained', (['model_id'], {}), '(model_id)\n', (17518, 17528), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((19673, 19707), 'langchain.llms.HuggingFacePipeline', 'HuggingFacePipeline', ([], {'pipeline': 'pipe'}), '(pipeline=pipe)\n', (19692, 19707), False, 'from langchain.llms import HuggingFacePipeline\n'), ((26365, 26412), 'langchain.chains.LLMChain', 'LLMChain', ([], {'llm': 'local_llm', 'prompt': 'prompt_template'}), '(llm=local_llm, prompt=prompt_template)\n', (26373, 26412), False, 'from langchain.chains import LLMChain\n'), ((26563, 26632), 'streamlit.success', 'st.success', (["('Input:  ' + user_input + '  \\n\\n ' + 'Output: ' + output)"], {}), "('Input:  ' + user_input + '  \\n\\n ' + 'Output: ' + output)\n", (26573, 26632), True, 'import streamlit as st\n'), ((26754, 26795), 'streamlit.error', 'st.error', (["('Model %s not found' % model_id)"], {}), "('Model %s not found' % model_id)\n", (26762, 26795), True, 'import streamlit as st\n'), ((17741, 17831), 'transformers.AutoModelForSeq2SeqLM.from_pretrained', 'AutoModelForSeq2SeqLM.from_pretrained', (['model_id'], {'load_in_8bit': '(False)', 'device_map': '"""auto"""'}), "(model_id, load_in_8bit=False,\n    device_map='auto')\n", (17778, 17831), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((17936, 18158), 'transformers.pipeline', 'pipeline', (['"""text2text-generation"""'], {'model': 'model_id', 'tokenizer': 'tokenizer', 'torch_dtype': '"""auto"""', 'trust_remote_code': '(True)', 'device_map': '"""auto"""', 'num_return_sequences': '(1)', 'eos_token_id': 'tokenizer.eos_token_id'}), "('text2text-generation', model=model_id, tokenizer=tokenizer,\n    torch_dtype='auto', trust_remote_code=True, device_map='auto',\n    num_return_sequences=1, eos_token_id=tokenizer.eos_token_id, **model_kwargs\n    )\n", (17944, 18158), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((18893, 19110), 'transformers.pipeline', 'pipeline', (['"""text-generation"""'], {'model': 'model_id', 'tokenizer': 'tokenizer', 'torch_dtype': '"""auto"""', 'trust_remote_code': '(True)', 'device_map': '"""auto"""', 'num_return_sequences': '(1)', 'eos_token_id': 'tokenizer.eos_token_id'}), "('text-generation', model=model_id, tokenizer=tokenizer,\n    torch_dtype='auto', trust_remote_code=True, device_map='auto',\n    num_return_sequences=1, eos_token_id=tokenizer.eos_token_id, **model_kwargs\n    )\n", (18901, 19110), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((20457, 20497), 'streamlit.status', 'st.status', (["('Loading model %s' % model_id)"], {}), "('Loading model %s' % model_id)\n", (20466, 20497), True, 'import streamlit as st\n'), ((20562, 20701), 'transformers.AutoModelForCausalLM.from_pretrained', 'AutoModelForCausalLM.from_pretrained', (['model_id'], {'trust_remote_code': '(True)', 'torch_dtype': 'torch.bfloat16', 'max_seq_len': '(2048)', 'device_map': '"""auto"""'}), "(model_id, trust_remote_code=True,\n    torch_dtype=torch.bfloat16, max_seq_len=2048, device_map='auto')\n", (20598, 20701), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((21156, 21212), 'transformers.AutoTokenizer.from_pretrained', 'AutoTokenizer.from_pretrained', (['"""EleutherAI/gpt-neox-20b"""'], {}), "('EleutherAI/gpt-neox-20b')\n", (21185, 21212), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((22359, 22638), 'transformers.pipeline', 'pipeline', ([], {'task': '"""text-generation"""', 'model': 'model', 'tokenizer': 'tokenizer', 'torch_dtype': '"""auto"""', 'device_map': '"""auto"""', 'num_return_sequences': '(1)', 'eos_token_id': 'tokenizer.eos_token_id', 'return_full_text': '(True)', 'stopping_criteria': 'stopping_criteria', 'repetition_penalty': '(1.1)'}), "(task='text-generation', model=model, tokenizer=tokenizer,\n    torch_dtype='auto', device_map='auto', num_return_sequences=1,\n    eos_token_id=tokenizer.eos_token_id, **model_kwargs, return_full_text=\n    True, stopping_criteria=stopping_criteria, repetition_penalty=1.1)\n", (22367, 22638), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((23366, 23400), 'langchain.llms.HuggingFacePipeline', 'HuggingFacePipeline', ([], {'pipeline': 'pipe'}), '(pipeline=pipe)\n', (23385, 23400), False, 'from langchain.llms import HuggingFacePipeline\n'), ((24320, 24360), 'streamlit.status', 'st.status', (["('Loading model %s' % model_id)"], {}), "('Loading model %s' % model_id)\n", (24329, 24360), True, 'import streamlit as st\n'), ((24425, 24546), 'transformers.AutoModelForCausalLM.from_pretrained', 'AutoModelForCausalLM.from_pretrained', (['model_id'], {'trust_remote_code': '(True)', 'torch_dtype': 'torch.bfloat16', 'device_map': '"""auto"""'}), "(model_id, trust_remote_code=True,\n    torch_dtype=torch.bfloat16, device_map='auto')\n", (24461, 24546), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((25301, 25514), 'transformers.pipeline', 'pipeline', ([], {'task': '"""text-generation"""', 'model': 'model', 'tokenizer': 'tokenizer', 'torch_dtype': '"""auto"""', 'device_map': '"""auto"""', 'num_return_sequences': '(1)', 'eos_token_id': 'tokenizer.eos_token_id', 'return_full_text': '(True)'}), "(task='text-generation', model=model, tokenizer=tokenizer,\n    torch_dtype='auto', device_map='auto', num_return_sequences=1,\n    eos_token_id=tokenizer.eos_token_id, **model_kwargs, return_full_text=True)\n", (25309, 25514), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((26078, 26112), 'langchain.llms.HuggingFacePipeline', 'HuggingFacePipeline', ([], {'pipeline': 'pipe'}), '(pipeline=pipe)\n', (26097, 26112), False, 'from langchain.llms import HuggingFacePipeline\n'), ((24937, 24992), 'transformers.AutoTokenizer.from_pretrained', 'AutoTokenizer.from_pretrained', (['model_id'], {'use_fast': '(False)'}), '(model_id, use_fast=False)\n', (24966, 24992), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n'), ((25156, 25195), 'transformers.AutoTokenizer.from_pretrained', 'AutoTokenizer.from_pretrained', (['model_id'], {}), '(model_id)\n', (25185, 25195), False, 'from transformers import AutoTokenizer, pipeline, AutoModelForSeq2SeqLM, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList\n')]