import streamlit as st import datasets from datasets import load_dataset import pandas as pd from streamlit.components.v1 import html from streamlit import markdown import re import os import time import json st.title('StackOverflow Question Demo') library = st.radio('Select a library', ('numpy', 'tensorflow+ pytorch', 'scipy', 'scikit-learn', 'pandas')) question_path = './{}.txt'.format(library) # loading stackoverflow questions. # using huggingface load_dataset function. # not done yet #@st.cache #def load_data(path): # return load_dataset('text', data_files = path, cache_dir = './data') intro = {'numpy': ''' #### Setup temperature = 0.7, topP = 0.95, turns = 10 #### Prompt: Problem: …… A: …… ###BEGIN SOLUTION [insert] ###END SOLUTION … A0: change example A1: change logits(decimal places, array, etc) A2: change output type (array -> dict, etc) A3: analogy A4: dimension(index) involved A5: inverted operation A6: order A7: ±condition/operation combinations involved, only show the highest level. ''', 'scipy': ''' #### Setup temperature = 0.7, topP = 0.95, 10 attempts. #### Prompt: Problem: …… A: …… ###BEGIN SOLUTION [insert] ###END SOLUTION … Origin: original question from stackoverflow(might be specified or simplified) Function: Let model fill in a function. A1: paraphrasing, seems not effective to Codex. A2: change example A3: analogy(min->max, column->row, etc) A6: result type constraint. A7: ±condition/operation ''' } hyper_links = {'numpy':'https://docs.google.com/document/d/1WjMXfe-zV5VvKfbUnyxauTBciPB1Bp82baaIrG3XffM/edit#', 'scipy': 'https://docs.google.com/document/d/1u_rGiLrLbH9Ac_OueTbmDFyLlWOtB0U56Ertp8ggW1Q/edit'} st.write(intro[library]) st.write('If the demo seems a little confusing, feel free to check the document.', hyper_links[library]) dataset = [] #dataset = load_data(question_path) with open(question_path) as f: lines = f.readlines() question = '' temp = {} tag = '' for line in lines: if line == 'Origin:\n' or line == 'Function:\n' or re.match(r'A\d:\n', line): if not tag: tag = line[:-2] else: temp[tag] = question question = '' tag = line[:-2] elif re.match(r'\d*\.\n', line): if tag: temp[tag] = question dataset.append(temp) question = '' tag = '' temp = {} else: if tag: question += line + '\n' temp[tag] = question dataset.append(temp) # Select index number = st.number_input("Insert a index: range from", min_value = 0, max_value = len(dataset) - 1) st.write('The current index is ', number) data_index = int(number) # Selece modification options = tuple(dataset[data_index].keys()) modification = st.radio('Modification:', options = options ) st.write(dataset[data_index][modification])