ejschwartz commited on
Commit
2d64e29
·
1 Parent(s): d868a6b

do some field stuff

Browse files
Files changed (1) hide show
  1. app.py +18 -5
app.py CHANGED
@@ -28,6 +28,23 @@ examples = [
28
  ]
29
 
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  @spaces.GPU
32
  def infer(code):
33
 
@@ -72,11 +89,7 @@ def infer(code):
72
  clean_up_tokenization_spaces=True,
73
  )
74
 
75
- field_helper_result = gradio_client.predict(
76
- decompiled_code=code,
77
- api_name="/predict",
78
- )
79
- print(field_helper_result)
80
 
81
  # field_output = fielddecoder_model.generate(
82
  # input_ids=input_ids,
 
28
  ]
29
 
30
 
31
+ # Example prompt
32
+ # "input": "```\n_BOOL8 __fastcall sub_409B9A(_QWORD *a1, _QWORD *a2)\n{\nreturn *a1 < *a2 || *a1 == *a2 && a1[1] < a2[1];\n}\n```\nWhat are the variable name and type for the following memory accesses:a1, a1[1], a2, a2[1]?\n",
33
+ # "output": "a1: a, os_reltime* -> sec, os_time_t\na1[1]: a, os_reltime* -> usec, os_time_t\na2: b, os_reltime* -> sec, os_time_t\na2[1]: b, os_reltime* -> usec, os_time_t",
34
+ def field_prompt(code):
35
+ field_helper_result = gradio_client.predict(
36
+ decompiled_code=code,
37
+ api_name="/predict",
38
+ )
39
+ print(f"field helper result: {field_helper_result}")
40
+
41
+ fields = sorted([e['expr'] for e in field_helper_result[0] if e['expr'] != ''])
42
+ print(f"fields: {fields}")
43
+
44
+ prompt = f"```\n{code}\n```\nWhat are the variable name and type for the following memory accesses:{', '.join(fields)}?\n"
45
+
46
+ return prompt, field_helper_result
47
+
48
  @spaces.GPU
49
  def infer(code):
50
 
 
89
  clean_up_tokenization_spaces=True,
90
  )
91
 
92
+ field_prompt_result, field_helper_result = field_prompt(code)
 
 
 
 
93
 
94
  # field_output = fielddecoder_model.generate(
95
  # input_ids=input_ids,