broadfield commited on
Commit
bff8ac8
·
verified ·
1 Parent(s): 05f5a16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -39
app.py CHANGED
@@ -119,48 +119,19 @@ def generate(prompt,history,mod=2,tok=4000,seed=1,role="ASSISTANT",data=None):
119
  yield 'test1'
120
  yield data[1]
121
  yield output
122
-
123
- #yield output
124
- #yield history
125
- #yield prompt
126
- #with open(f'{loc_folder}/{loc_file}.json','w') as jobj:
127
- # lod.append({'prompt':prompt,'response':output,'image':im_box,'model':clients[1]['name'],'seed':seed}),
128
- # jobj.write(json.dumps(lod,indent=4))
129
- #jobj.close()
130
- #chat_im_out=chat_img(output)
131
 
132
- '''def gen_im(prompt,seed):
133
- print('generating image')
134
- image_out = im_client.text_to_image(prompt=prompt['text'],height=128,width=128,num_inference_steps=10,seed=seed)
135
- #print(type(image_out))
136
- output=f'images/{uuid.uuid4()}.png'
137
- image_out.save(output)
138
- print('Done: ',output)
139
- return [{'role':'assistant','content': {'path':output}}]'''
140
  def parse_json(inp):
141
  print("PARSE INPUT")
142
  print(inp)
143
  if type(inp)==type(""):
144
  lines=""
145
  if "```" in inp:
146
- start = inp.find("```json") + 7 # Find index after the start character
147
- end = inp.find("```", start) # Find index of end character from the start index
148
  if start >= 0 and end >= 0:
149
- inp= inp[start:end] # Slice the string between start and end
150
  else:
151
- inp="NONE" # Return None if characters not found
152
- '''tog=False
153
- cnt=0
154
- for line in inp.split("\n"):
155
- if tog==True:
156
- if not "```" in line:
157
- lines+=line
158
- if "```" in line:
159
- cnt+=1
160
- if cnt==1:
161
- tog = True
162
- elif cnt==2:
163
- tog = False'''
164
  print("Extracted Lines")
165
  print(inp)
166
  try:
@@ -189,12 +160,6 @@ def build_space(repo_name,file_name,file_content,access_token=""):
189
  private=False,
190
  )
191
 
192
- # Create a new Space
193
- #response = api.create_repo(repo_path)
194
- #space_info = repo_url.json()
195
- #print(space_info)
196
- #space_id = space_info["name"]
197
- #print(f"Created Space with ID: {space_id}")
198
  local_file_path=str(uuid.uuid4())
199
  with open(local_file_path, 'w') as f:
200
  f.write(str(file_content))
 
119
  yield 'test1'
120
  yield data[1]
121
  yield output
 
 
 
 
 
 
 
 
 
122
 
 
 
 
 
 
 
 
 
123
  def parse_json(inp):
124
  print("PARSE INPUT")
125
  print(inp)
126
  if type(inp)==type(""):
127
  lines=""
128
  if "```" in inp:
129
+ start = inp.find("```json") + 7
130
+ end = inp.find("```", start)
131
  if start >= 0 and end >= 0:
132
+ inp= inp[start:end]
133
  else:
134
+ inp="NONE"
 
 
 
 
 
 
 
 
 
 
 
 
135
  print("Extracted Lines")
136
  print(inp)
137
  try:
 
160
  private=False,
161
  )
162
 
 
 
 
 
 
 
163
  local_file_path=str(uuid.uuid4())
164
  with open(local_file_path, 'w') as f:
165
  f.write(str(file_content))